Thursday, April 30, 2009

Simple Curl Request using PHP

$submiturl = "http://192.168.1.101/phpdocs/missing_man/curl/index.php";

/* INIT CURL */
$ch = curl_init($submiturl);

/*
CURLOPT_RETURNTRANSFER = 1 ; it will NOT directly display the return value
CURLOPT_RETURNTRANSFER = 0 ; it will directly display the return value
*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable

/* EXECUTE */
$result = curl_exec($ch);


$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($statusCode == 200) {
echo "CURL Status : Working !!";
echo "
";
echo "Return Data :";
echo $result;
} else {
echo "CURL is not Working ??";
}
?>

more info.. http://evergreenphp.blogspot.com

No comments: