Пример #1
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 or $parameters = array();
     $defaults = array("oauth_version" => nsx_trOAuthRequest::$version, "oauth_nonce" => nsx_trOAuthRequest::generate_nonce(), "oauth_timestamp" => nsx_trOAuthRequest::generate_timestamp(), "oauth_consumer_key" => $consumer->key);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new nsx_trOAuthRequest($http_method, $http_url, $parameters);
 }
 function getCurrentShare($parameters = '')
 {
     $search_url = $this->base_url . "/v1/people/~/current-share";
     $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $search_url);
     $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
     $auth_header = $request->to_header("https://api.linkedin.com");
     if ($debug) {
         echo $request->get_signature_base_string() . "\n";
         echo $auth_header . "\n";
     }
     $response = $this->httpRequest($search_url, $auth_header, "GET");
     return $response;
 }
Пример #3
0
 function setStatus($status)
 {
     $status_url = $this->base_url . "/v1/people/~/current-status";
     //echo "Setting status...\n";
     $xml = "<current-status>" . htmlspecialchars($status, ENT_NOQUOTES, "UTF-8") . "</current-status>";
     //echo $xml . "\n";
     $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "PUT", $status_url);
     $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
     $auth_header = $request->to_header("https://api.linkedin.com");
     if ($debug) {
         echo $auth_header . "\n";
     }
     $response = $this->httpRequest($status_url, $auth_header, "PUT", $xml);
     // prr($response);
     return $response;
 }
Пример #4
0
 /**
  * Format and sign an OAuth / API request
  */
 function oAuthRequest($url, $method, $parameters)
 {
     if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
         $url = "{$this->host}{$url}";
     }
     $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
     $request->sign_request($this->sha1_method, $this->consumer, $this->token);
     switch ($method) {
         case 'GET':
             return $this->http($request->to_url(), 'GET');
         default:
             return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
     }
 }