PHP
--
Questions
--
Followers
Top Experts
PHP > CURL > CURLOPT_PROXY
Running the below code returns with cURL error code of "7" which is "CURLE_COULDNT_CONNECT"
If the two proxy lines are commented out, the code runs fine.
What do I need to change to get CURLOPT_PROXY running?
Thanks,
http://www.t1shopper.com/
PS. As of the time I posted this, the proxy IP address in the source code was working as tested with FoxyProxy. Â Full list of error codes at http://curl.haxx.se/libcurl/c/libcurl-errors.html
If the two proxy lines are commented out, the code runs fine.
What do I need to change to get CURLOPT_PROXY running?
Thanks,
http://www.t1shopper.com/
PS. As of the time I posted this, the proxy IP address in the source code was working as tested with FoxyProxy. Â Full list of error codes at http://curl.haxx.se/libcurl/c/libcurl-errors.html
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); //The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //The maximum number of seconds to allow cURL functions to execute.
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 0); //TRUE to force the use of a new connection instead of a cached one.
curl_setopt($ch, CURLOPT_PROXY, '66.173.241.16');
curl_setopt($ch, CURLOPT_PROXYPORT, '80');
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); //Toggles whether non-HTTP transactions are tunnelled through an HTTP proxy (as set up with CURLOPT_PROXY, for instance). This option is only available if the cURL version is 7.3 or later and the PHP version is 4.0.4 or later. Unless you know exactly why you need to use this option, you probably don't.
curl_setopt($ch, CURLOPT_HEADER, 0); //TRUE to include the header in the output.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 0); //TRUE to return the raw output when CURLOPT_RETURNTRANSFER is used.
curl_setopt($ch, CURLINFO_HEADER_OUT, 1); //if you want to use curl_getinfo() with option CURLINFO_HEADER_OUT in order to debug your cURL request, you must add curl_setopt($handle, CURLINFO_HEADER_OUT, true); first while specifying the options.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
curl_setopt($ch, CURLOPT_FAILONERROR, 1); //TRUE to fail silently if the HTTP code returned is greater than or equal to 400. The default behavior is to return the page normally, ignoring the code.
$data=curl_exec($ch);
echo __LINE__,' : ',curl_errno($ch),"\r\n";
echo __LINE__,' : ';print_r(curl_getinfo($ch)); echo "\r\n";
echo __LINE__,' : ',$data;
?>
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Hello t1shopper,
Where's your proxy "66.173.241.16" ? Not on your local network ?
Have you good response time when you use it with an internet browser ?
Regards.
Where's your proxy "66.173.241.16" ? Not on your local network ?
Have you good response time when you use it with an internet browser ?
Regards.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
PHP
--
Questions
--
Followers
Top Experts
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.