Jump to content

cURL is driving me crazy please help


papaface

Recommended Posts

Hey,

 

I am about to go insane so please can someone come to my aid lol.

 

My code:

function download($url)
{
$curl = curl_init();

if($curl)
{
     if( !curl_setopt($curl, CURLOPT_URL, $url) ) return "FAIL: curl_setopt(CURLOPT_URL)";
     if( !curl_setopt($curl, CURLOPT_HEADER, array("Accept: text/xml,application/xml,application/xhtml+xml,text/html,;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept-Language: en-us,en;q=0.5", "Connection: keep-alive", "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.4) Gecko/20070625 Ubuntu/7.10 (gutsy) Firefox/3.0.0.7", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300")) ) return "FAIL: curl_setopt(CURLOPT_HEADER)";
 $ret = curl_exec($curl);
     if( !$ret ) return "FAIL: curl_exec()";
     curl_close($curl);

if	(strpos($ret, "Payment Required") > 0)
	{ 
	return "Payment is required <br />";
	}
else
	{
	return $ret;
	}
}
else return "FAIL: curl_init()";
}

Sample of cURL output:

HTTP/1.1 402 Payment Required Date: Thu, 10 Dec 2009

Why would that show when I am asking it to return "Payment is required <br />" if the $ret var contains the string "Payment Required"?

 

Any help would be appreciated :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.