本文整理汇总了PHP中Zend_Http_Client::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client::getUri方法的具体用法?PHP Zend_Http_Client::getUri怎么用?PHP Zend_Http_Client::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client
的用法示例。
在下文中一共展示了Zend_Http_Client::getUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetUriObject
/**
* Test we can SET and GET a URI as object
*
*/
public function testSetGetUriObject()
{
$uriobj = Zend_Uri::factory('http://www.zend.com:80/');
$this->client->setUri($uriobj);
$uri = $this->client->getUri();
$this->assertTrue($uri instanceof Zend_Uri_Http, 'Returned value is not a Uri object as expected');
$this->assertEquals($uri, $uriobj, 'Returned object is not the excepted Uri object');
}
示例2: _getInfo
/**
* Protected method that queries REST service and returns SimpleXML response set
*
* @param string $service name of Audioscrobbler service file we're accessing
* @param string $params parameters that we send to the service if needded
* @throws Zend_Http_Client_Exception
* @throws Zend_Service_Exception
* @return SimpleXMLElement result set
* @access protected
*/
protected function _getInfo($service, $params = null)
{
$service = (string) $service;
$params = (string) $params;
if ($params === '') {
$this->getHttpClient()->setUri("http://ws.audioscrobbler.com{$service}");
} else {
$this->getHttpClient()->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
}
$response = $this->getHttpClient()->request();
$responseBody = $response->getBody();
if (preg_match('/No such path/', $responseBody)) {
throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
} elseif (preg_match('/No user exists with this name/', $responseBody)) {
throw new Zend_Http_Client_Exception('No user exists with this name');
} elseif (!$response->isSuccessful()) {
throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
}
set_error_handler(array($this, '_errorHandler'));
if (!($simpleXmlElementResponse = simplexml_load_string($responseBody))) {
restore_error_handler();
$exception = new Zend_Service_Exception('Response failed to load with SimpleXML');
$exception->error = $this->_error;
$exception->response = $responseBody;
throw $exception;
}
restore_error_handler();
return $simpleXmlElementResponse;
}
示例3: getInfo
/**
*
* Private method that queries REST service and returns SimpleXML response set
* @param string $service name of Audioscrobbler service file we're accessing
* @param string $params parameters that we send to the service if needded
* @return SimpleXML result set
*/
private function getInfo($service, $params = NULL)
{
$service = (string) $service;
$params = (string) $params;
try {
if ($params == "") {
$this->_client->setUri("http://ws.audioscrobbler.com{$service}");
} else {
$this->_client->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
}
if ($this->testing == TRUE) {
$adapter = new Zend_Http_Client_Adapter_Test();
$this->_client->setConfig(array('adapter' => $adapter));
$adapter->setResponse($this->testing_response);
}
$request = $this->_client->request();
$response = $request->getBody();
if ($response == 'No such path') {
throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
} else {
if ($response == 'No user exists with this name.') {
throw new Zend_Http_Client_Exception('No user exists with this name');
} else {
if ($request->isError()) {
throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
} else {
return simplexml_load_string($response);
}
}
}
} catch (Zend_Http_Client_Exception $e) {
throw $e;
}
}
示例4: task
public function task(Zend_Http_Response $response, Zend_Http_Client $client)
{
$timerStart = microtime(true);
get_headers($client->getUri());
$timerEnd = microtime(true);
$this->totalPages++;
$this->totalTime += $timerEnd - $timerStart;
}
示例5: testSetGetUriObject
/**
* Test we can SET and GET a URI as object
*
*/
public function testSetGetUriObject()
{
$uriobj = new URI\URL('http://www.zend.com:80/');
$this->_client->setUri($uriobj);
$uri = $this->_client->getUri();
$this->assertTrue($uri instanceof URI\URL, 'Returned value is not a Uri object as expected');
$this->assertEquals($uri, $uriobj, 'Returned object is not the excepted Uri object');
}
示例6: testSetCookieObjectArray
/**
* Make sure we can set an array of object cookies
*
*/
public function testSetCookieObjectArray()
{
$this->client->setUri($this->baseuri . 'testCookies.php');
$refuri = $this->client->getUri();
$cookies = array('chocolate' => 'chips', 'crumble' => 'apple', 'another' => 'cookie');
$this->client->setCookies($cookies);
$res = $this->client->send();
$this->assertEquals($res->getBody(), serialize($cookies), 'Response body does not contain the expected cookies');
}
示例7: get
/**
* Get OpenSocial data for an OpenSocial URI
*
* Using the following syntax:
* /people/{uid}/@all with params array('uid' => 'john.doe')
* will cause the HTTP client to use the following uri:
* /people/123%20abc/@all
*
* @example $client->get('/people/{uid}/@all', array('uid' => 'john.doe'));
*
* @param string $uri (Prepared) OpenSocial URI
* @param array $params Data for prepared URI
* @return array Models for OpenSocial data (/person returns OpenSocial_Model_Person objects, etc.)
*/
public function get($uri, $params = array())
{
$uri = $this->_getPreparedUri($uri, $params);
$uri = $this->_prependSlash($uri);
$serviceType = $this->_getServiceTypeFromUri($uri);
$uri = $this->_httpClient->getUri(true) . $uri;
$response = $this->_httpClient->setUri($uri)->request(Zend_Http_Client::GET);
return $this->_mapResponseToModels($serviceType, $response);
}
示例8: testRedirectWithTrailingSpaceInLocationHeaderZF11283
/**
* Test that we can handle trailing space in location header
*
* @group ZF-11283
* @link http://framework.zend.com/issues/browse/ZF-11283
*/
public function testRedirectWithTrailingSpaceInLocationHeaderZF11283()
{
$this->_client->setUri('http://example.com/');
$this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
$adapter = $this->_client->getAdapter();
/* @var $adapter Zend_Http_Client_Adapter_Test */
$response = "HTTP/1.1 302 Redirect\r\n" . "Content-Type: text/html; charset=UTF-8\r\n" . "Location: /test\r\n" . "Server: Microsoft-IIS/7.0\r\n" . "Date: Tue, 19 Apr 2011 11:23:48 GMT\r\n\r\n" . "RESPONSE";
$adapter->setResponse($response);
$res = $this->_client->request('GET');
$lastUri = $this->_client->getUri();
$this->assertEquals("/test", $lastUri->getPath());
}
示例9: getInfo
/**
* Private method that queries REST service and returns SimpleXML response set
*
* @param string $service name of Audioscrobbler service file we're accessing
* @param string $params parameters that we send to the service if needded
* @throws Zend_Http_Client_Exception
* @throws Zend_Service_Exception
* @return SimpleXMLElement result set
*/
private function getInfo($service, $params = null)
{
$service = (string) $service;
$params = (string) $params;
if ($params === '') {
$this->_client->setUri("http://ws.audioscrobbler.com{$service}");
} else {
$this->_client->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
}
if ($this->_testing) {
/**
* @see Zend_Http_Client_Adapter_Test
*/
require_once 'Zend/Http/Client/Adapter/Test.php';
$adapter = new Zend_Http_Client_Adapter_Test();
$this->_client->setConfig(array('adapter' => $adapter));
$adapter->setResponse($this->_testingResponse);
}
$request = $this->_client->request();
$response = $request->getBody();
if ($response == 'No such path') {
throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
} else if ($response == 'No user exists with this name.') {
throw new Zend_Http_Client_Exception('No user exists with this name');
} else if ($request->isError()) {
throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
}
set_error_handler(array($this, '_errorHandler'));
if (!$simpleXmlElementResponse = simplexml_load_string($response)) {
restore_error_handler();
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
$exception = new Zend_Service_Exception('Response failed to load with SimpleXML');
$exception->error = $this->_error;
$exception->response = $response;
throw $exception;
}
restore_error_handler();
return $simpleXmlElementResponse;
}
示例10: testSetCookieObjectJar
/**
* Make sure we can set cookie objects with a jar
*
*/
public function testSetCookieObjectJar()
{
$this->client->setUri($this->baseuri . 'testCookies.php');
$this->client->setCookieJar();
$refuri = $this->client->getUri();
$cookies = array(Zend_Http_Cookie::fromString('chocolate=chips', $refuri), Zend_Http_Cookie::fromString('crumble=apple', $refuri));
$strcookies = array();
foreach ($cookies as $c) {
$this->client->setCookie($c);
$strcookies[$c->getName()] = $c->getValue();
}
$res = $this->client->request();
$this->assertEquals($res->getBody(), serialize($strcookies), 'Response body does not contain the expected cookies');
}
示例11: provisionUser
/**
*
*
* @param $userId
* @param $attributes
* @param $spMetadata
* @param $idpMetadata
* @return void
*/
public function provisionUser($userId, $attributes, $spMetadata, $idpMetadata)
{
if (!$spMetadata['MustProvisionExternally']) {
return;
}
// https://os.XXX.surfconext.nl/provisioning-manager/provisioning/jit.shtml?
// provisionDomain=apps.surfnet.nl&provisionAdmin=admin%40apps.surfnet.nl&
// provisionPassword=xxxxx&provisionType=GOOGLE&provisionGroups=true
$client = new Zend_Http_Client($this->_url);
$client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json; charset=utf-8')->setParameterGet('provisionType', $spMetadata['ExternalProvisionType'])->setParameterGet('provisionDomain', $spMetadata['ExternalProvisionDomain'])->setParameterGet('provisionAdmin', $spMetadata['ExternalProvisionAdmin'])->setParameterGet('provisionPassword', $spMetadata['ExternalProvisionPassword'])->setParameterGet('provisionGroups', $spMetadata['ExternalProvisionGroups'])->setRawData(json_encode($this->_getData($userId, $attributes)))->request('POST');
$additionalInfo = new EngineBlock_Log_Message_AdditionalInfo($userId, $idpMetadata['EntityId'], $spMetadata['EntityId'], null);
EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: Sent HTTP request to provision user using " . __CLASS__, $additionalInfo);
EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: URI: " . $client->getUri(true), $additionalInfo);
EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: REQUEST: " . $client->getLastRequest(), $additionalInfo);
EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: RESPONSE: " . $client->getLastResponse(), $additionalInfo);
}
示例12: _applyFilters
/**
* @return $this
* @throws Zend_Http_Client_Exception
*/
protected function _applyFilters()
{
if (empty($this->_filters)) {
return $this;
}
$uri = $this->_http->getUri(true);
foreach ($this->_filters as $key => $value) {
/** is some filters already applied */
if (!strpos($uri, '?')) {
$uri .= '?';
} else {
$uri .= '&';
}
$uri .= $key . '=' . $value;
}
$this->_http->setUri($uri);
return $this;
}
示例13: post
function post($url = null, $params = null, $config = array())
{
$_config = array();
$arrParams = array();
//-----------------
// Установим URL
if ($url) {
$this->client->setUri($url);
} else {
$url = $this->client->getUri(TRUE);
}
// Установим параметры запроса
if ($params) {
if (is_string($params)) {
// Преобразуем строку запроса в массив
parse_str($params, $arrParams);
$this->client->setParameterPost($arrParams);
} else {
$this->client->setParameterPost($params);
}
}
// Установим заголовок Referer
if (!empty($this->last_url)) {
$_config['headers']['Referer'] = $this->last_url;
}
// Запомним последний URL
$this->last_url = $url;
// Обьединим два массива
$config = $_config + $config;
// Сохраним последнюю конфигурацию
$this->last_config = $this->_setConfig($config);
// Выполним запрос
$response = $this->client->request("POST");
$html = $response->getBody();
// Запомним последний запрос в виде строки
$this->last_request = $this->client->getLastRequest();
// Запомним последний запрос в виде Zend_Http_Response
$this->last_response = $this->client->getLastResponse();
// Запомним последние полученные Сookies
$this->last_cookies = $this->client->getCookieJar()->getAllCookies();
return new PGPage($this->client->getUri(TRUE), $this->clean($html), $this);
}
示例14: getClientUrl
function getClientUrl(Zend_Http_Client $client)
{
$string = '';
try {
$c = clone $client;
/*
* Assume there is nothing on 80 port.
*/
$c->setUri('http://127.0.0.1');
$c->getAdapter()->setConfig(array('timeout' => 0));
$c->request();
} catch (Exception $e) {
$string = $c->getLastRequest();
$string = substr($string, 4, strpos($string, "HTTP/1.1\r\n") - 5);
}
return $client->getUri(true) . $string;
}
示例15: browserReceive
/**
* @param Zend_Http_Client $xhr
*/
public static function browserReceive($xhr)
{
phpQuery::debug("[WebBrowser] Received from " . $xhr->getUri(true));
// TODO handle meta redirects
$body = $xhr->getLastResponse()->getBody();
// XXX error ???
if (strpos($body, '<!doctype html>') !== false) {
$body = '<html>' . str_replace('<!doctype html>', '', $body) . '</html>';
}
$pq = phpQuery::newDocument($body);
$pq->document->xhr = $xhr;
$pq->document->location = $xhr->getUri(true);
$refresh = $pq->find('meta[http-equiv=refresh]')->add('meta[http-equiv=Refresh]');
if ($refresh->size()) {
// print htmlspecialchars(var_export($xhr->getCookieJar()->getAllCookies(), true));
// print htmlspecialchars(var_export($xhr->getLastResponse()->getHeader('Set-Cookie'), true));
phpQuery::debug("Meta redirect... '{$refresh->attr('content')}'\n");
// there is a refresh, so get the new url
$content = $refresh->attr('content');
$urlRefresh = substr($content, strpos($content, '=') + 1);
$urlRefresh = trim($urlRefresh, '\'"');
// XXX not secure ?!
phpQuery::ajaxAllowURL($urlRefresh);
// $urlRefresh = urldecode($urlRefresh);
// make ajax call, passing last $xhr object to preserve important stuff
$xhr = phpQuery::ajax(array('type' => 'GET', 'url' => $urlRefresh, 'dataType' => 'html'), $xhr);
if ($xhr->getLastResponse()->isSuccessful()) {
// if all is ok, repeat this method...
return call_user_func_array(array('phpQueryPlugin_WebBrowser', 'browserReceive'), array($xhr));
}
} else {
return $pq;
}
}