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


PHP OAuthRequest::set_parameter方法代码示例

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


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

示例1: testUnsetParameter

 public function testUnsetParameter()
 {
     $request = new OAuthRequest('', '');
     $this->assertEquals(NULL, $request->get_parameter('test'));
     $request->set_parameter('test', 'foo');
     $this->assertEquals('foo', $request->get_parameter('test'));
     $request->unset_parameter('test');
     $this->assertEquals(NULL, $request->get_parameter('test'), 'Failed to unset parameter');
 }
开发者ID:kawahara,项目名称:test_mobile_app,代码行数:9,代码来源:OAuthRequestTest.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


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