I'm using https://github.com/rmccue/Requests
I'm making a request using a random Proxy sometimes the proxy will work sometimes it will fail: with different errors:
Uncaught exception 'Requests_Exception' with message 'cURL error 28: connect() timed out!'
My question is: How can I catch this CURL error, and try another another proxy in a loop?
I tried var_dump($request->status_code); it outputs 200 reguardless of success or fail.
include('../library/Requests.php');
// Next, make sure Requests can load internal classes
Requests::register_autoloader();
// Now let's make a request via a proxy.
$options = array(
'proxy' => '$randomProxyIP:$randomProxyPort')
);
$request = Requests::get('http://httpbin.org/ip', array(), $options );
var_dump($request->status_code);