Post data using curl

$aUrl = '####';
$aData= array('key1' => 'val1','key2' => 'val2');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($aData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone
  

What is cUrl

  • cUrl is a tool to transfer data from one server to another via URL.
  • cUrl is library in php that help to make HTTP requests

Examples :

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://mysite.com");
$output = curl_exec($ch);
curl_close($ch);     
?>
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone
  
Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.