Beispiel #1
0
 /**
  * Format and sign an OAuth / API request
  */
 private function oauth_request($url, $method, $parameters)
 {
     $request = Yoast_OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
     $request->sign_request($this->signature_method, $this->consumer, $this->token);
     if ('GET' == $method) {
         return wp_remote_get($request->to_url());
     } else {
         return wp_remote_post($request->to_url(), $request->to_postdata());
     }
 }
 /**
  * pretty much a helper function to set up the request
  */
 public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = null)
 {
     $parameters = $parameters ? $parameters : array();
     $defaults = array('oauth_version' => Yoast_OAuthRequest::$version, 'oauth_nonce' => Yoast_OAuthRequest::generate_nonce(), 'oauth_timestamp' => Yoast_OAuthRequest::generate_timestamp(), 'oauth_consumer_key' => $consumer->key);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new Yoast_OAuthRequest($http_method, $http_url, $parameters);
 }