Skip to content

Instantly share code, notes, and snippets.

@dbarbar
Created July 17, 2012 20:27
Show Gist options
  • Select an option

  • Save dbarbar/3131828 to your computer and use it in GitHub Desktop.

Select an option

Save dbarbar/3131828 to your computer and use it in GitHub Desktop.
Using curl to retrive a JSON URL and decode it.
$apiurl = 'the url';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$data = json_decode($json);
var_export($data);
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment