本文整理匯總了PHP中Zend\Http\Client::getResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getResponse方法的具體用法?PHP Client::getResponse怎麽用?PHP Client::getResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Http\Client
的用法示例。
在下文中一共展示了Client::getResponse方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testUnsubscriptionRequestSendsExpectedPostData
public function testUnsubscriptionRequestSendsExpectedPostData()
{
$this->_subscriber->setTopicUrl('http://www.example.com/topic');
$this->_subscriber->addHubUrl($this->_baseuri . '/testRawPostData.php');
$this->_subscriber->setCallbackUrl('http://www.example.com/callback');
$this->_subscriber->setTestStaticToken('abc');
//override for testing
$this->_subscriber->unsubscribeAll();
$this->assertEquals('hub.callback=http%3A%2F%2Fwww.example.com%2Fcallback%3Fxhub.subscription%3D5536df06b5d' . 'cb966edab3a4c4d56213c16a8184b&hub.mode=unsubscribe&hub.topic=http' . '%3A%2F%2Fwww.example.com%2Ftopic&hub.verify=sync&hub.verify=async' . '&hub.verify_token=abc', $this->_client->getResponse()->getBody());
}
示例2: testIfCookiesAreSticky
public function testIfCookiesAreSticky()
{
$initialCookies = array(
new SetCookie('foo', 'far', null, '/', 'www.domain.com' ),
new SetCookie('bar', 'biz', null, '/', 'www.domain.com')
);
$requestString = "GET http://www.domain.com/index.php HTTP/1.1\r\nHost: domain.com\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:16.0) Gecko/20100101 Firefox/16.0\r\nAccept: */*\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\n";
$request = Request::fromString($requestString);
$client = new Client('http://www.domain.com/');
$client->setRequest($request);
$client->addCookie($initialCookies);
$cookies = new Cookies($client->getRequest()->getHeaders());
$rawHeaders = "HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Encoding: gzip\r\nContent-Type: application/javascript\r\nDate: Sun, 18 Nov 2012 16:16:08 GMT\r\nServer: nginx/1.1.19\r\nSet-Cookie: baz=bah; domain=www.domain.com; path=/\r\nSet-Cookie: joe=test; domain=www.domain.com; path=/\r\nVary: Accept-Encoding\r\nX-Powered-By: PHP/5.3.10-1ubuntu3.4\r\nConnection: keep-alive\r\n";
$response = Response::fromString($rawHeaders);
$client->setResponse($response);
$cookies->addCookiesFromResponse($client->getResponse(), $client->getUri());
$client->addCookie( $cookies->getMatchingCookies($client->getUri()) );
$this->assertEquals(4, count($client->getCookies()));
}
示例3: testGetLastRawResponse
/**
* Test the getLastRawResponse() method actually returns the last response
*
*/
public function testGetLastRawResponse()
{
// First, make sure we get null before the request
$this->assertEquals(null, $this->_client->getLastRawResponse(), 'getLastRawResponse() is still expected to return null');
// Now, test we get a proper response after the request
$this->_client->setUri('http://example.com/foo/bar');
$this->_client->setAdapter('Zend\\Http\\Client\\Adapter\\Test');
$response = $this->_client->send();
$this->assertTrue($response === $this->_client->getResponse(), 'Response is expected to be identical to the result of getResponse()');
}
示例4: setCoordinates
/**
* ustawia wspolrzedne geograficzne dla lokalizacji
*
* @param Entity\Location $location
* @return Entity\Location
*/
public function setCoordinates(Entity\Location $location)
{
$location->getAddress();
$client = new Http\Client('http://maps.googleapis.com/maps/api/geocode/json');
$client->setParameterGet(array('address' => $location->getAddress()));
$client->send();
$response = json_decode($client->getResponse()->getBody());
/**
* w wymaganiach nie ma obslugi przypadkow uzycia
* - zapisuje lokalizacje pierwszego 'dopasowanego' przez google adresu
*
*/
if ($response->status === 'OK' && !empty($results = $response->results[0])) {
$location->setLatitude($results->geometry->location->lat)->setLongitude($results->geometry->location->lng);
}
return $location;
}
示例5: doRequest
/**
* 發起請求
* @param $requestUrl
* @param $adapterOpt
* @return \Zend\Http\Response
*/
public function doRequest($requestUrl, $adapterOpt = [])
{
$client = new Client();
$client->setAdapter($this->session->getSessionAdapter($adapterOpt));
$client->setUri($requestUrl);
$client->setMethod(Request::METHOD_POST);
$client->send();
$response = $client->getResponse();
$setCookies = $response->getCookie();
$this->session->updateSessionCookie($setCookies);
return $response;
}