Skip to content

Instantly share code, notes, and snippets.

@radermacher
Created December 11, 2012 08:07
Show Gist options
  • Save radermacher/4256734 to your computer and use it in GitHub Desktop.
Save radermacher/4256734 to your computer and use it in GitHub Desktop.
cURL: send data and get response
$url = 'http://domain.tld/path/to/file/or/route/';
$data = $_REQUEST;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //POST, GET, DELETE, PUT
$output = curl_exec($ch);
curl_close($ch);
echo $output;
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment