Solved

curl proxy signup

Posted on 2013-05-25
2
332 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 110

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ajax and PHP 9 53
Checking https returns 301 21 54
Get value in session when using dynamic information 24 38
syntax error, unexpected '?' in phpunit 5 22
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

685 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