Answer the question
In order to leave comments, you need to log in
How to implement stable work through a proxy through Zend_Http_Client?
I'm trying to set up requests to the server through a proxy. I am using the Zend_Http_Client library.
Here is a simple query example
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
'proxy_host' => '***.***.***.***',
'proxy_port' => 3180,
);
$client = new Zend_Http_Client('http://google.com', $config);
$response=$client->request();
echo $response->getBody();
class ...
public function ...
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
'proxy_host' => '***.***.***.***',
'proxy_port' => 3180,
);
$client = new Zend_Http_Client('http://google.com', $config);
$response=$this->tryConnect($client);
echo $response->getBody();
...
public function tryConnect(Zend_Http_Client $client, $i=1) {
try {
return $client->request();
} catch(Zend_Http_Client_Adapter_Exception $exception) {
if($i>7) {
throw new CException($exception->getMessage());
} else {
return $this->tryConnect($client, ++$i);
}
}
}
...
Answer the question
In order to leave comments, you need to log in
Take a proxy aggregator, like freeproxy.ru, cling to their API to get a list of proxies, get a list of proxies, take the first one from the list, try to download content through it. If it fails, remove the proxy from the list, try the next one.
Once every N minutes, update the proxy list.
Anonymous proxies (I see that you are trying to google through anonymous proxies) are such a thing that no one guarantees their performance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question