Skip to content

Instantly share code, notes, and snippets.

@swappyp20
Forked from maxparm/instagram.php
Last active August 29, 2015 14:23
Show Gist options
  • Save swappyp20/cc76e69b4a5af881bdf1 to your computer and use it in GitHub Desktop.
Save swappyp20/cc76e69b4a5af881bdf1 to your computer and use it in GitHub Desktop.
<?php
//Get data from instagram api
$hashtag = 'max';
//Query need client_id or access_token
$query = array(
'client_id' => '',
'count' => 3
);
$url = 'https://api.instagram.com/v1/tags/'.$hashtag.'/media/recent?'.http_build_query($query);
try {
$curl_connection = curl_init($url);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
//Data are stored in $data
$data = json_decode(curl_exec($curl_connection), true);
curl_close($curl_connection);
} catch(Exception $e) {
return $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment