本文整理汇总了PHP中Guzzle\Http\Message\Request::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getQuery方法的具体用法?PHP Request::getQuery怎么用?PHP Request::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOnRequestBeforeSend
public function testOnRequestBeforeSend()
{
$request = new Request('GET', 'https://example.com');
$event = new Event(['request' => $request]);
$oauth = new OAuth('example');
$oauth->onRequestBeforeSend($event);
$this->assertTrue($request->getQuery()->hasKey('access_token'));
$this->assertEquals('example', $request->getQuery()->get('access_token'));
}
示例2: testValidRawSignature
/**
* Testing the raw signature value before it's hashed.
*
* Signatures should match Ooyala's {@link http://support.ooyala.com/developers/documentation/tasks/api_signing_requests.html Signing Request Algorithm}.
*/
public function testValidRawSignature()
{
$method = 'GET';
$path = '/my/path';
$key = '123';
$secret = '456';
// Purposely out of order to test sorting from the Response object query params.
$queryParams = array('fake' => 'fake,param', 'another' => '123', 'key' => $key);
$request = new Request($method, $path);
foreach ($queryParams as $key => $val) {
$request->getQuery()->set($key, $val);
unset($key, $val);
}
$signature = new Signature($secret, $request);
// Build expected signature by hand to simulate what \SheKnows\OoyalaApi\Signature::getRawSignature() does.
// @see \SheKnows\OoyalaApi\Signature for more details.
$expected = $secret . $method . $path;
ksort($queryParams);
// Sort manually, kind of makes for an ugly test :/
foreach ($queryParams as $key => $val) {
$expected .= "{$key}={$val}";
}
$this->assertEquals($expected, $signature->getRawSignature(), 'Raw signature should match {secret} + {HttpMethod} + {UriPath} + {ordered_query_params}');
$this->assertEquals(43, strlen($signature), 'Hashed signature should be 43 characters in length.');
}
示例3: setGetParameters
/**
* Functio to set GET parameters onto the
* request
*
* @param array $params Key value array of get params
*/
public function setGetParameters($params = array())
{
$query = $this->request->getQuery();
foreach ($params as $key => $val) {
$query->add($key, $val);
}
}
示例4: addQuery
private function addQuery(Request $request, $timestamp, $nonce)
{
$query = $request->getQuery();
$query->add(self::$keys['OAuthVersionKey'], self::$oAuthVersion);
$query->add(self::$keys['OAuthTimestampKey'], $timestamp);
$query->add(self::$keys['OAuthNonceKey'], $nonce);
$query->add(self::$keys['OAuthSignatureMethodKey'], 'HMAC-SHA1');
$query->add(self::$keys['OAuthConsumerKeyKey'], self::$consumer_key);
}
示例5: testCreatesCanonicalizedQueryString
/**
* @covers Aws\Common\Signature\AbstractSignature::getCanonicalizedQueryString
* @dataProvider queryStringProvider
*/
public function testCreatesCanonicalizedQueryString($headers, $string)
{
// Make the method publicly callable
$method = new \ReflectionMethod('Aws\\Common\\Signature\\AbstractSignature', 'getCanonicalizedQueryString');
$method->setAccessible(true);
// Create a request and replace the headers with the test headers
$request = new Request('GET', 'http://www.example.com');
$request->getQuery()->replace($headers);
$this->assertEquals($string, $method->invoke($this->signature, $request));
}
示例6: testAssertEmptyParametersAreStrippedWhenSignRequest
/**
* @covers PusherSignature::signRequest
*/
public function testAssertEmptyParametersAreStrippedWhenSignRequest()
{
$request = new HttpRequest('POST', '/apps/3/events');
// We set variables in query to have always the same result
$request->getQuery()->replace(array('key-with-value' => 'value', 'key-without-value' => ''));
$this->pusherSignature->signRequest($request, $this->credentials);
$queryParameters = $request->getQuery()->toArray();
$this->assertArrayHasKey('key-with-value', $queryParameters);
$this->assertArrayNotHasKey('key-without-value', $queryParameters);
}
示例7: testClonedRequestsUseNewInternalState
/**
* @covers Guzzle\Http\Message\Request::__clone
*/
public function testClonedRequestsUseNewInternalState()
{
$p = new AsyncPlugin();
$this->request->getEventDispatcher()->addSubscriber($p);
$h = $this->request->getHeader('Host');
$r = clone $this->request;
$this->assertEquals(RequestInterface::STATE_NEW, $r->getState());
$this->assertNotSame($r->getQuery(), $this->request->getQuery());
$this->assertNotSame($r->getCurlOptions(), $this->request->getCurlOptions());
$this->assertNotSame($r->getEventDispatcher(), $this->request->getEventDispatcher());
$this->assertEquals($r->getHeaders(), $this->request->getHeaders());
$this->assertNotSame($h, $r->getHeader('Host'));
$this->assertNotSame($r->getParams(), $this->request->getParams());
$this->assertTrue($this->request->getEventDispatcher()->hasListeners('request.sent'));
}
示例8: fromRequest
public function fromRequest(Request $request, $secretKey)
{
$method = strtolower($request->getMethod());
switch ($method) {
case 'post':
case 'patch':
case 'put':
case 'delete':
$body = (string) $request->getBody();
break;
default:
$body = $request->getQuery(true);
}
return $this->generate($body, $secretKey);
}
示例9: signRequest
/**
* @param \Guzzle\Http\Message\Request $request
*/
public function signRequest(Request $request)
{
$url = $request->getPath();
if ('POST' == $request->getMethod() && $request instanceof EntityEnclosingRequest) {
$body = (string) $request->getBody();
$hash = $this->signature->generate($body);
} else {
$url .= '?' . $request->getQuery();
$hash = $this->signature->generate($url);
}
$request->addCookie('acquia_solr_time', $this->signature->getRequestTime());
$request->addCookie('acquia_solr_nonce', $this->signature->getNonce());
$request->addCookie('acquia_solr_hmac', $hash . ';');
// The timestamp should be current for each request.
$this->signature->unsetRequestTime();
}
示例10: addApiKey
/**
* @param \Guzzle\Http\Message\Request $request
* @param string $apiKey
*
* @return \BigOven\BigOvenAuthPlugin
*/
public function addApiKey(Request $request, $apiKey)
{
$request->getQuery()->set('api_key', $apiKey);
return $this;
}
示例11: updateQueryParams
/**
* @param GuzzleRequest $request
*/
private function updateQueryParams(GuzzleRequest $request)
{
foreach ($this->queryParams as $name => $value) {
$request->getQuery()->add($name, $value);
}
}
示例12: prepareQuery
/**
* Prepare the query string before the API request.
*
* @param \Guzzle\Http\Message\Request $request
* @param array $tricks
*
* @return \Guzzle\Http\Message\Request
*/
protected function prepareQuery(GuzzleRequest $request, $tricks)
{
$threads = $this->getThreadsArray($tricks);
$aggregator = $this->getQueryAggregator();
$request->getQuery()->set('forum', $this->getConfig('forum'))->set('thread', $threads)->set('api_key', $this->getConfig('publicKey'))->setAggregator($aggregator);
return $request;
}
示例13: getQueryString
public function getQueryString()
{
return (string) $this->_request->getQuery();
}
示例14: preprocessRequest
/**
* Allow adapter to modify request before sending,
* adding API key by default
*
* @param Request $request
*/
protected function preprocessRequest(Request $request)
{
$request->getQuery()->add('key', $this->getApiKey());
}
示例15: getParamsToSign
public function getParamsToSign(\Guzzle\Http\Message\Request $request)
{
return $request->getQuery()->toArray();
}