当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuthRequest::sign_request方法代码示例

本文整理汇总了PHP中OAuthRequest::sign_request方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthRequest::sign_request方法的具体用法?PHP OAuthRequest::sign_request怎么用?PHP OAuthRequest::sign_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuthRequest的用法示例。


在下文中一共展示了OAuthRequest::sign_request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param 	object 	An optional KConfig object with configuration options
  */
 public function __construct($config = array())
 {
     if (is_array($config)) {
         $config = new KConfig($config);
     }
     parent::__construct($config);
     $params = new KConfig();
     $this->_data = KConfig::unbox($config->data);
     if (is_array($this->_data)) {
         $params->append($this->_data);
     }
     $params->append(array('oauth_version' => $config->version));
     $this->_internal_request = OAuthRequest::from_consumer_and_token($config->consumer, $config->token, $config->method, $config->url, KConfig::unbox($params));
     if (!empty($config->signature)) {
         $this->_internal_request->sign_request($config->signature, $config->consumer, $config->token);
     }
     $this->_options = $config->options;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:23,代码来源:request.php

示例2: sign

 /**
  * Sign the request using OAuth. This uses the consumer token and key
  * but 2 legged oauth doesn't require an access token and key. In situations where you want to
  * do a 'reverse phone home' (aka: gadget does a makeRequest to your server
  * and your server wants to retrieve more social information) this is the prefered
  * method.
  *
  * @param string $method the method (get/put/delete/post)
  * @param string $url the url to sign (http://site/social/rest/people/1/@me)
  * @param array $params the params that should be appended to the url (count=20 fields=foo, etc)
  * @param string $postBody for POST/PUT requests, the postBody is included in the signature
  * @return string the signed url
  */
 public function sign($method, $url, $params = array(), $postBody = false, &$headers = array())
 {
     $oauthRequest = new OAuthRequest($method, $url, $params);
     $params = $this->mergeParameters($params);
     foreach ($params as $key => $val) {
         if (is_array($val)) {
             $val = implode(',', $val);
         }
         $oauthRequest->set_parameter($key, $val);
     }
     if ($postBody && strlen($postBody)) {
         if ($this->useBodyHash) {
             $bodyHash = base64_encode(sha1($postBody, true));
             $oauthRequest->set_parameter("oauth_body_hash", $bodyHash);
         }
         if ($this->useBodyHack) {
             $oauthRequest->set_parameter($postBody, '');
         }
     }
     $oauthRequest->sign_request($this->signatureMethod, $this->consumerToken, $this->accessToken);
     if ($postBody && $this->useBodyHack) {
         unset($oauthRequest->parameters[$postBody]);
     }
     $signedUrl = $oauthRequest->to_url();
     return $signedUrl;
 }
开发者ID:vznet,项目名称:vz_os_clientlibrary_php,代码行数:39,代码来源:osapiOAuth2Legged.php

示例3: _performRequest

 /**
  * Performs a OAuthRequest, returning the response
  * You can give a token to force signatures with this
  * token. If none given, the token used when creating
  * this instance of CampusNotesAPI is used
  * @param OAuthRequest $req
  * @param OAuthToken $token 
  * @return string
  * @throws CNApiException
  */
 private function _performRequest(OAuthRequest $req, OAuthToken $token = null)
 {
     $token = $token ? $token : $this->oauth_token;
     $req->sign_request($this->hmac_signature_method, $this->oauth_consumer, $token);
     $curl = curl_init();
     $params = $req->get_parameters();
     foreach (array_keys($params) as $i) {
         if (substr($i, 0, 6) == 'oauth_') {
             unset($params[$i]);
         }
     }
     $url = $req->get_normalized_http_url();
     if ($req->get_normalized_http_method() == 'POST') {
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
     } else {
         if (count($params)) {
             $url .= '?' . http_build_query($params);
         }
     }
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array($req->to_header()));
     $rtn = curl_exec($curl);
     if (!$rtn) {
         throw new OAuthClientException(curl_error($curl));
     } else {
         if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200) {
             throw new OAuthClientException($rtn);
         } else {
             return $rtn;
         }
     }
 }
开发者ID:redspider,项目名称:Entrecredits-API,代码行数:44,代码来源:EccOAuth.php

示例4: __build_oauth_header

 private function __build_oauth_header($linkedin_url)
 {
     $request = new OAuthRequest('GET', $linkedin_url, array('oauth_nonce' => OAuthRequest::generate_nonce(), 'oauth_timestamp' => OAuthRequest::generate_timestamp(), 'oauth_version' => '1.0', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_consumer_key' => $this->oaConsumerKey, 'oauth_token' => OAUTH_USER_TOKEN));
     $request->sign_request($this->signature, new OAuthConsumer('', $this->oaConsumerSecret), new OAuthToken('', '95b27494-0a99-47c0-a66c-533cef4b8a28'));
     return $request->to_header();
 }
开发者ID:manoj-samosys,项目名称:linkedin-api-quick-start-php,代码行数:6,代码来源:linkedin.php


注:本文中的OAuthRequest::sign_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。