aabid Posted July 5, 2011 Share Posted July 5, 2011 Hey Guys, Am developing a script which will send a request to a server through PHP's CURL using proxy, but I don't know why requests are not passing through whenever I use use proxy option of CURL. And when I remove that proxies everything works fine, Here is the code, function getit($url, $start, $msg = "") { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: Mozilla/5.0 (SymbianOS/9.1; U; [en-us]) AppleWebKit/413 (KHTML, like Gecko) Safari/413"); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0); curl_setopt($ch, CURLOPT_PROXY, $this->proxy); curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:pass'); curl_setopt($ch, CURLOPT_PROXYAUTH, 'CURLPROXY_BASIC'); curl_setopt($ch, CURLOPT_PROXYTYPE, 'CURLAUTH_BASIC'); if(!$start) { curl_setopt($ch, CURLOPT_POST, TRUE); } curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_ENCODING, "" ); if($msg) { $msg = str_replace(" ", "+", $msg); $msg = "msg=".$msg."&".$this->unique; curl_setopt($ch, CURLOPT_POSTFIELDS, $msg); } else { if(!$start) { curl_setopt($ch, CURLOPT_POSTFIELDS, $this->unique); } } curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*")); $this->content = curl_exec($ch); if(!$this->content) { echo "Requests are not passing through\n"; echo "Error ".curl_error($ch)."\n"; } return $this->content; } I've searched and tried everything but still not working, please help me to get rid of it Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/ Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 Not even a single reply C'mon guys where are the guru's of this awesome community Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238437 Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 still no reply Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238599 Share on other sites More sharing options...
Amit20 Posted July 5, 2011 Share Posted July 5, 2011 Just a question??? Have u uncommented curl dll in php.ini file??? Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238619 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 Are you sure it's an HTTP proxy? What curl errors are you getting? Probably connection failures. Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238633 Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 Ya cURL is active in php.ini function and also its working when am not using proxies so no question about that. However how would I know whether its a HTTP proxy or not ? All I know is 3 type of proxies public, private and anonymous. I know for sure that the one am using is anonymous proxy. Would it be a problem ? Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238665 Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 Are you sure it's an HTTP proxy? What curl errors are you getting? Probably connection failures. Am getting this error ERROR The requested URL could not be retrieved The following error was encountered while trying to retrieve the URL: http://www.yahoo.com Access Denied. Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect. Your cache administrator is webmaster. Generated Tue, 05 Jul 2011 19:30:02 GMT by funky_blue (squid/3.0.STABLE19) Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238668 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 There you go. Proxy won't let you connect. Is this a public proxy, or one you've paid for? Your best bet is to ask whoever is providing you this proxy how to cURL through it. HTTP proxy is a proxy that allows communication over the HTTP protocol Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238683 Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 There you go. Proxy won't let you connect. Is this a public proxy, or one you've paid for? Your best bet is to ask whoever is providing you this proxy how to cURL through it. HTTP proxy is a proxy that allows communication over the HTTP protocol but when am using that through my firefox it works and I can surf easily but why not in PHP script ??? I know for sure that its a anonymous proxy...Do I need more information than that ? Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238691 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 Possibly the authorization. Is it needed? Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238693 Share on other sites More sharing options...
aabid Posted July 5, 2011 Author Share Posted July 5, 2011 Possibly the authorization. Is it needed? I don't know what authorization means but in my knowledge it is providing valid username and password I assume and am providing that. Beside that I've also tried to both include and remove following line, curl_setopt($ch, CURLOPT_PROXYAUTH, 'CURLPROXY_BASIC'); curl_setopt($ch, CURLOPT_PROXYTYPE, 'CURLAUTH_BASIC'); yet also nothing works and it shows the same. What I noticed though is when I comment out the line containing CURLOPT_PROXYUSERPWD, still the error remains same or atleast it looks same in browser output. Might be because of that but am not sure.... Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238695 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 You'll have to check with the owner of the proxy. This isn't a PHP issue, and it is well beyond anything we can help you with. The most I can do is, 'try this, try that, etc' For some reason, the proxy server is rejecting your attempt to cURL through it. Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1238706 Share on other sites More sharing options...
aabid Posted July 7, 2011 Author Share Posted July 7, 2011 AM tired with this thing now, can't devise a solution for this. I don't know why the proxy is refusing connection when am trying that with my script. I asked from my proxy provider how to curl and he simply sent me PHP code which was almost same as of mine with no help. I also sent a basic base64 of my username:password in a header to make it authorized still its refusing connections. Please help me guys..... Quote Link to comment https://forums.phpfreaks.com/topic/241107-cant-use-php-curl-help/#findComment-1239663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.