Skip to content

Instantly share code, notes, and snippets.

@josuecau
Created October 11, 2013 07:49
Show Gist options
  • Save josuecau/6931095 to your computer and use it in GitHub Desktop.
Save josuecau/6931095 to your computer and use it in GitHub Desktop.
cURL PHP examples
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://domain.tld');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($curl);
curl_close($curl);
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://domain.tld');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
'foo' => 'bar'
));
$return = curl_exec($curl);
curl_close($curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment