Solved

curl proxy signup

Posted on 2013-05-25
2
326 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 108

Accepted Solution

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

Author Closing Comment

by:rgb192
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now