mercredi 26 octobre 2016

It is possible get the medio of another user? Instgram API

This code that I took form another web, works! but only when I put my Instragram ID. Otherwise when I want to get a media from another user (changing the variable userid) it stops working.

To be sure I use http://ift.tt/2dIzGKJ to get the user ID. And to get the Access Token (only with my account): http://ift.tt/1WIG82j

<?php
    // Supply a user id and an access token
    $userid = "-----";
    $accessToken = "---";

    // Gets our data
    function fetchData($url){
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, 20);
         $result = curl_exec($ch);
         curl_close($ch); 
         return $result;
    }
    // Pulls and parses data.
    $result = fetchData("http://ift.tt/1xuNkVb}");
    $result = json_decode($result);
    ?>
<?php if(!empty($result->data)): ?>
    <?php foreach ($result->data as $post): ?>
        <!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
        <a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
    <?php endforeach ?>
<?php endif ?>




Aucun commentaire:

Enregistrer un commentaire