afimafis Posted April 9, 2012 Share Posted April 9, 2012 Hello, hello i need use curl with proxy. but i get "undefined variable offset 1" error . here is the standart code i use. please help me about it thanks curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $agent); Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/ Share on other sites More sharing options...
Jessica Posted April 9, 2012 Share Posted April 9, 2012 Post the entire error, the relevant code (ie, what is $proxy) and use code tags next time. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335709 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 jesirose thanks for reply i am sure that proxy works well. but i guess problem is related curl proxy settings. codes are standart i used. i will be very appreciated, if u give me any clues thanks Post the entire error, the relevant code (ie, what is $proxy) and use code tags next time. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335717 Share on other sites More sharing options...
RobertP Posted April 9, 2012 Share Posted April 9, 2012 Post the entire error, the relevant code (ie, what is $proxy) and use code tags next time. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335725 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 the point i am sure is page can not loaded on time.even if i use timeout as 20 seconds i dont know what i missed thanks Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335732 Share on other sites More sharing options...
Jessica Posted April 9, 2012 Share Posted April 9, 2012 I've never seen someone so stubborn set against actually getting help. Impressive. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335741 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 sorry //## Init cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E; .NET CLR 1.1.4322)"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_PROXY, 202.182.124.12:3128); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txtt"); curl_setopt($ch, CURLOPT_URL, "https:.........................."); $page = curl_exec($ch); print_r($page); Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335746 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 If you add quotes around the proxy IP and add echo curl_error() at the end: Received HTTP code 403 from proxy after CONNECT You've used that proxy in your browser and it worked without authentication? Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335753 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 sorry i forgot to add quatoes. but i am sure that it works on web browser. no errror gottten Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335757 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 Don't set CURLOPT_HTTPPROXYTUNNEL. Take out that line. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335763 Share on other sites More sharing options...
Jessica Posted April 9, 2012 Share Posted April 9, 2012 sorry i forgot to add quatoes. but i am sure that it works on web browser. no errror gottten This makes me think of some weird combination of quotes and potatoes. Quoted potatoes guys. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335764 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 i will very happy, if u help me :-\ sorry i forgot to add quatoes. but i am sure that it works on web browser. no errror gottten This makes me think of some weird combination of quotes and potatoes. Quoted potatoes guys. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335775 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 Like I said before, take out this line: curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); This proxy doesn't need it. Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335781 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 Like I said before, take out this line: curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); This proxy doesn't need it. i tried but nothing changed Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335782 Share on other sites More sharing options...
dcro2 Posted April 9, 2012 Share Posted April 9, 2012 Works for me. $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E; .NET CLR 1.1.4322)"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_PROXY, "202.182.124.12:3128"); // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txtt"); curl_setopt($ch, CURLOPT_URL, "https://www.google.com"); $page = curl_exec($ch); echo $page; echo curl_error($ch); What error do you get now? Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335793 Share on other sites More sharing options...
afimafis Posted April 9, 2012 Author Share Posted April 9, 2012 i tested . works well for me. but i changed proxies. %90 of them gets this error 216.155.139.115:3128 117.27.139.17:80 i tested these proxies 5 minutes ago. they are level1 proxies "Received HTTP code 403 from proxy after CONNECT" Works for me. $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E; .NET CLR 1.1.4322)"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_PROXY, "202.182.124.12:3128"); // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txtt"); curl_setopt($ch, CURLOPT_URL, "https://www.google.com"); $page = curl_exec($ch); echo $page; echo curl_error($ch); What error do you get now? Quote Link to comment https://forums.phpfreaks.com/topic/260619-php-curl-proxy-problem/#findComment-1335804 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.