我有类似的东西:
$client = new Zend_Http_Client('http://www.site.com');
$client->setParameterGet(array(
'platform' => $platform,
'clientId' => $clientId,
'deploymentId' => $deploymentId,
));
try {
$response = $client->request();
...
这会生成类似于'http://www.site.com/?plataform = ..?clientid?..'的请求。 有没有办法可以检索此GET请求生成的完整URL? 亲切的问候,
答案 0 :(得分:1)
令人惊讶的是,没有直接的方法来获取完整的请求字符串。 BUT
function getClientUrl (Zend_Http_Client $client)
{
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;
}
$client = new Zend_Http_Client ('http://yahoo.com');
$client->setParameterGet ('q', 'search string');
echo getClientUrl ($client);