array( array('content' => 'http://oauth.net/discovery/1.0') ), 'URI' => array( array('content' => '#oauth' ) ), ) ); register_xrd('oauth'); register_xrd_service('oauth', 'OAuth Request Token', array( 'Type' => array( array('content' => 'http://oauth.net/core/1.0/endpoint/request'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1'), ), 'URI' => array( array('content' => get_bloginfo('wpurl').'/wp-content/plugins/wp-oauth/request_token.php' ) ), ) ); register_xrd_service('oauth', 'OAuth Authorize Token', array( 'Type' => array( array('content' => 'http://oauth.net/core/1.0/endpoint/authorize'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), ), 'URI' => array( array('content' => get_bloginfo('wpurl').'/wp-content/plugins/wp-oauth/authorize_token.php' ) ), ) ); register_xrd_service('oauth', 'OAuth Access Token', array( 'Type' => array( array('content' => 'http://oauth.net/core/1.0/endpoint/access'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1'), ), 'URI' => array( array('content' => get_bloginfo('wpurl').'/wp-content/plugins/wp-oauth/access_token.php' ) ), ) ); register_xrd_service('oauth', 'OAuth Resources', array( 'Type' => array( array('content' => 'http://oauth.net/core/1.0/endpoint/resource'), array('content' => 'http://oauth.net/core/1.0/parameters/uri-query'), array('content' => 'http://oauth.net/core/1.0/signature/HMAC-SHA1'), ), ) ); register_xrd_service('oauth', 'OAuth Static Token', array( 'Type' => array( array('content' => 'http://oauth.net/discovery/1.0/consumer-identity/static'), ), 'LocalID' => array( array('content' => 'DUMMYKEY' ) ), ) ); }//end if ! oauth }//end if register_xrd $services = get_option('oauth_services'); $services['Post Comments'] = array('wp-comments-post.php'); $services['Edit and Create Entries and Categories'] = array('wp-app.php'); update_option('oauth_services', $services); $store = new OAuthWordpressStore(); $server = new OAuthServer($store); $sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); $plaintext_method = new OAuthSignatureMethod_PLAINTEXT(); $server->add_signature_method($sha1_method); $server->add_signature_method($plaintext_method); try { $req = OAuthRequest::from_request(); list($consumer, $token) = $server->verify_request($req); $userid = $store->user_from_token($consumer->key, $token->key); $authed = get_usermeta($userid, 'oauth_consumers'); $authed = $authed[$consumer->key]; if($authed && $authed['authorized']) { $allowed = false; foreach($authed as $ends) if(is_array($ends)) foreach($ends as $end) if(strstr($_SERVER['SCRIPT_URI'], $end)) $allowed = true; if($allowed) set_current_user($userid); }//end if } catch (OAuthException $e) {/* We may not be doing OAuth at all. */} }//end function oauth_accept //if(!$NO_oauth) oauth_accept(); function oauth_page() { global $wpdb; if($_POST['new_consumer']) { $store = new OAuthWordpressStore(); $store->new_consumer($_POST['new_consumer']); echo '
New Consumer pair generated.