function prepare_authentication_header($url)
 {
     $signature_method = new Google_Analytics_OAuthSignatureMethod_HMAC_SHA1();
     $consumer = new Google_Analytics_OAuthConsumer('anonymous', 'anonymous', NULL);
     $token = new Google_Analytics_OAuthConsumer($this->oauth_token, $this->oauth_secret);
     $oauth_req = Google_Analytics_OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url, array());
     $oauth_req->sign_request($signature_method, $consumer, $token);
     $headers = $oauth_req->to_header();
     $headers = explode(": ", $headers);
     $headers[$headers[0]] = $headers[1];
     return $headers;
 }
Ejemplo n.º 2
0
 /**
  * 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" => Google_Analytics_OAuthRequest::$version, "oauth_nonce" => Google_Analytics_OAuthRequest::generate_nonce(), "oauth_timestamp" => Google_Analytics_OAuthRequest::generate_timestamp(), "oauth_consumer_key" => $consumer->key);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new Google_Analytics_OAuthRequest($http_method, $http_url, $parameters);
 }