/**
 * 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' => bebop_oauth_request::$version, 'oauth_nonce' => bebop_oauth_request::generate_nonce(), 'oauth_timestamp' => bebop_oauth_request::generate_timestamp(), 'oauth_consumer_key' => $consumer->key, 'oauth_callback' => $consumer->callback_url);
     if ($token) {
         $defaults['oauth_token'] = $token->key;
     }
     $parameters = array_merge($defaults, $parameters);
     return new bebop_oauth_request($http_method, $http_url, $parameters);
 }
示例#2
0
 public function oauth_request_post_xml($url)
 {
     if ($this->get_parameters()) {
         $parameters = $this->get_parameters();
     } else {
         $parameters = null;
     }
     $consumer = $this->get_consumer();
     $accessToken = $this->get_consumer($this->get_access_token(), $this->get_access_token_secret(), $this->get_callback_url());
     $req = bebop_oauth_request::from_consumer_and_token($consumer, $accessToken, 'POST', $url, $this->get_parameters());
     $sig = new bebop_signature_method_HMAC_SHA1();
     $req->sign_request($sig, $consumer, $accessToken);
     $ci = curl_init();
     curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ci, CURLOPT_URL, $url);
     curl_setopt($ci, CURLOPT_VERBOSE, FALSE);
     $header = array($req->to_header('http://api.linkedin.com'));
     $header[] = 'Content-Type: text/xml; charset=UTF-8';
     curl_setopt($ci, CURLOPT_POSTFIELDS, $this->getPostData());
     curl_setopt($ci, CURLOPT_HTTPHEADER, $header);
     $response = curl_exec($ci);
     curl_close($ci);
 }