Skip to content

Instantly share code, notes, and snippets.

@morecchia
Last active August 29, 2015 13:57
Show Gist options
  • Save morecchia/9570364 to your computer and use it in GitHub Desktop.
Save morecchia/9570364 to your computer and use it in GitHub Desktop.
cUrl script to get discogs api data
<?php
$url = "http://api.discogs.com/"; // add the resource info to the url. Ex. releases/1
//initialize the session
$ch = curl_init();
//Set the User-Agent Identifier
curl_setopt($ch, CURLOPT_USERAGENT, 'YOUR_APP_NAME_HERE/0.1 +http://your-site-here.com');
//Set the URL of the page or file to download.
curl_setopt($ch, CURLOPT_URL, $url);
//Ask cURL to return the contents in a variable instead of simply echoing them
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Execute the curl session
$output = curl_exec($ch);
//close the session
curl_close ($ch);
echo $output
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment