Wrote this for one of my projects - hopefully it helps you out a little bit. POST data needs to be formatted variable1=value&variable2=value2 and urlencoded.
function CURL($url, $postdat=""){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
if($postdat){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdat);
}
while(!$dat) $dat = curl_exec($ch);
curl_close($ch);
return $dat;
}
Examples:
$dat = CURL("http://google.com");
$dat = CURL("http://site.com/post.php", "search=bunnies");
Sorry I haven't had much content lately: finals this week :-\




December 18th, 2007 at 2:53 am
Complexity.
December 18th, 2007 at 8:22 pm
CURL using Firefox? You must drive a Volvo too.
December 19th, 2007 at 5:53 pm
You're both right, of course, but it doesn't make me hate you any less.
January 26th, 2008 at 1:46 pm
Just found Curl in my server stats and searched for curl on google and ended up here.
it looks like someone is scraping my content?
January 26th, 2008 at 2:13 pm
More than likely, yes. You can probably block that user-agent without it affecting your normal traffic if you don't want them to.