Solved

curl proxy signup

Posted on 2013-05-25
2
330 Views
Last Modified: 2013-05-28
$config['use_proxy'] = FALSE;
$config['proxy'] = 'proxy.domain.com:3128';
$config['proxy_username'] = '';
$config['proxy_password'] = '';

Open in new window


function http_post_call($url = '', $referer = '', $postdata = '', $include_header = FALSE)
{
	global $config;
	global $gacookie;
	$arr_result = array();

	$ch = curl_init();

	if ($include_header !== FALSE)
		curl_setopt ($ch, CURLOPT_HEADER, TRUE);

	curl_setopt ($ch, CURLOPT_AUTOREFERER, 1);
	curl_setopt ($ch, CURLOPT_COOKIESESSION, 0);
	curl_setopt ($ch, CURLOPT_FAILONERROR, 0);
	curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
	curl_setopt ($ch, CURLOPT_FRESH_CONNECT, 1);
	curl_setopt ($ch, CURLOPT_POST, 1);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt ($ch, CURLOPT_UNRESTRICTED_AUTH, 1);

	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
	curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
	if ($config['use_proxy'] !== FALSE)
	{
		curl_setopt ($ch, CURLOPT_PROXY, $config['proxy']);
		curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $config['proxy_username'].':'.$config['proxy_password']);
	}

	curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
	curl_setopt ($ch, CURLOPT_COOKIEJAR, $gacookie);
	curl_setopt ($ch, CURLOPT_ENCODING, "");
	curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
	curl_setopt ($ch, CURLOPT_REFERER, $referer);
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0");

	$response = curl_exec($ch);
	$error = curl_error($ch);
	$info = curl_getinfo($ch);
	$err_no = curl_errno($ch);

	curl_close($ch);
	unset($ch);

	if ($err_no)
	{
	  echo $error;
	  echo '<META http-equiv="refresh" content="'.$config['refresh_interval'].'; URL=index.php"><br /><br />Back to the <a href="index.php">main page</a>.';
	  exit();
	}
	
	$arr_result['response'] = $response;
	$arr_result['error'] 	= $error;
	$arr_result['info'] 	= $info;
	$arr_result['err_no'] 	= $err_no;
	
	return $arr_result;
}

Open in new window



how to run this curl class by using a proxy

where to sign up for this type of proxy
0
Comment
Question by:rgb192
2 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39196989
Where does this come from?  Is there an online document that describes the API?
0
 

Author Closing Comment

by:rgb192
ID: 39202932
I can not discover the answers to these important questions, so it is not supported, I will look for another code sample
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why do people dis php? 5 50
tutorial for ebay api 3 35
000webhost.com default error log 1 28
Is there a simpler dropbox system? 10 22
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question