/**
  * 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" => BuddyStreamOAuthRequest::$version, "oauth_nonce" => BuddyStreamOAuthRequest::generate_nonce(), "oauth_timestamp" => BuddyStreamOAuthRequest::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 BuddyStreamOAuthRequest($http_method, $http_url, $parameters);
 }
 public function oAuthRequestPostXml($url)
 {
     if ($this->getParameters()) {
         $parameters = $this->getParameters();
     } else {
         $parameters = null;
     }
     $consumer = $this->getConsumer();
     $accessToken = $this->getConsumer($this->getAccessToken(), $this->getAccessTokenSecret(), $this->getCallbackUrl());
     $req = BuddyStreamOAuthRequest::from_consumer_and_token($consumer, $accessToken, 'POST', $url, $this->getParameters());
     $req->sign_request(new BuddyStreamOAuthSignatureMethod_HMAC_SHA1(), $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);
     return $response;
 }
 function oAuthRequest($url)
 {
     if ($this->getParameters()) {
         $parameters = $this->getParameters();
     } else {
         $parameters = null;
     }
     $consumer = $this->getConsumer();
     $accessToken = $this->getConsumer($this->getAccessToken(), $this->getAccessTokenSecret(), $this->getCallbackUrl());
     $req = BuddyStreamOAuthRequest::from_consumer_and_token($consumer, $accessToken, $this->getRequestType(), $url, $parameters);
     $req->sign_request(new BuddyStreamOAuthSignatureMethod_HMAC_SHA1(), $consumer, $accessToken);
     if ($this->getRequestType() == 'GET') {
         return $this->executeRequest($req->to_url());
     } else {
         $this->setPostData($req->to_postdata());
         return $this->executeRequest($req->get_normalized_http_url());
     }
 }