Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2010, 11:15 PM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot use CURL with PROXY

I have a function which is an extended version of SimplePies Simplepie_File class which accesses web based content either through CURL or fsockopen.

I am trying to update it so that it can use a proxy to access the content and the fsockopen branch works fine but whenever I try to access any page through a proxy with CURL I get the following error

error 56: Proxy CONNECT aborted

If I try a very simple CURL function like the following I get the same issue

Code:
 $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	
	if(!empty($proxy)){
		curl_setopt($ch, CURLOPT_PROXY, "xx.xx.xx.xx:8080");
		curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
	}
	
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_USERAGENT, "some user agent");
 
    $result['CONTENT'] = curl_exec($ch);
    $result['INFO'] = curl_getinfo($ch);
    $result['ERROR'] = curl_error($ch);
 
    curl_close($ch);
 
	print_r($result);
I get the following in the result

Array ( [CONTENT] => [INFO] => Array ( [url] => http://www.darkpolitricks.com [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 123 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.734 [namelookup_time] => 0 [connect_time] => 0.375 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 ) [ERROR] => Proxy CONNECT aborted )

Without using a proxy I can access any web content perfectly well so its only an issue with Proxies AND CURL as if I use file_get_contents or fsockopen then I can go through proxies no problem.

I have not found much help on Google and am pretty new to PHP. I have checked all the .ini settings, extensions and settings but cannot see anything I should enable.

I am running this on my windows XP laptop through WAMPSERVER on my localhost.

Any help would be much appreciated

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
java and proxy PeterPeiGuo Pro Java 1 April 1st, 2009 12:32 AM
why isn't CURL logging me in ? jjk2 Beginning PHP 1 October 5th, 2008 07:29 PM
cURL is resubmitting the page diamondField PHP How-To 1 September 23rd, 2008 04:25 PM
curl spbharti Pro PHP 1 April 20th, 2006 02:34 PM
PHP CURL set root domain mfoozzz PHP How-To 0 April 6th, 2006 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.