Skip to content

Instantly share code, notes, and snippets.

@marczhermo
Created April 1, 2012 07:05
Show Gist options
  • Save marczhermo/2272304 to your computer and use it in GitHub Desktop.
Save marczhermo/2272304 to your computer and use it in GitHub Desktop.
PHP: Curl
<?php
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://api.github.com");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// grab URL and pass it to the browser
$filedata = curl_exec($ch);
echo '<pre>';var_dump($filedata);
// close curl resource, and free up system resources
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment