How to use instagram api to retrieve an image using a specific hashtag?

I am studying the instagram api to get some hashtag image on my website recently.

After searching the Internet for a very long time, I coundnt find some workable code for it.

Anyone can help?

Thanks!

+7
javascript api php instagram
source share
3 answers

If you need to display the database of images only in the tag, then you should not include the wrapper class "instagram.class.php". Because the Media and Tag endpoints in the Instagram API do not require authentication. You can use the following curl function to get results based on your tag.

function callInstagram($url) { $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2 )); $result = curl_exec($ch); curl_close($ch); return $result; } $tag = 'YOUR_TAG_HERE'; $client_id = "YOUR_CLIENT_ID"; $url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent?client_id='.$client_id; $inst_stream = callInstagram($url); $results = json_decode($inst_stream, true); //Now parse through the $results array to display your results... foreach($results['data'] as $item){ $image_link = $item['images']['low_resolution']['url']; echo '<img src="'.$image_link.'" />'; } 
+12
source share

You will need to use the API endpoint to get a list of recently tagged materials with a hashtag. It would look like to get media for the hashtag #superpickle

 https://api.instagram.com/v1/tags/superpickle/media/recent 

You will need to read the Instagram API documentation to learn more about this and how to register for a customer ID. http://instagram.com/developer/

+5
source share

You can use the statigram cURL method, isnt Instagram API, but you can solve it. I use CodeIgniter and create a service to return XML, usign simple_xml_load to read the feed. Good Lucky.

 $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_URL, "http://statigr.am/feed/cristiano"); $content = curl_exec($curl); curl_close($curl); $this->xml = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA); echo json_encode($this->xml->channel); 
0
source share