Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

curl proxy signup

Posted on 2013-05-25
2
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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.

705 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