本文整理汇总了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');
}
示例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;
}