Simple use of CURL
06 January, 2009

Here is a very simple structure of how to use curl with post method –


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://example.com/target.php');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);	
curl_setopt($ch, CURLOPT_POST , 1);// setting up to use post method
curl_setopt($ch, CURLOPT_POSTFIELDS, array("fieldName1"=>"data1","fieldName2"=>"data2"));							
$content = curl_exec($ch);
curl_close($ch);

---

Commenting is closed for this article.