Sergey Scopin
Sergey Scopin

Reputation: 2245

Instagram api getting photos without getting link

I need get photos and descriptions from registered instagram. As I understand from docs on github https://github.com/cosenary/Instagram-PHP-API You need put auth link first ant then using auth token after click on it you are redirected to some callback url, where you can get media then. But can I somehow login automatically without clicking link?? I have some

$instagram = new Instagram(array(
    'apiKey'      => 'apiKey',
    'apiSecret'   => 'apiSecret',
    'apiCallback' => 'apiCallback there'
));

with my data get after registration in https://www.instagram.com/developer/. How can I get what I want?

Upvotes: 1

Views: 247

Answers (1)

MPC
MPC

Reputation: 42

I guess try something like this:

        $userid = "User-ID-Goes-Here";
        $accessToken = "Token-Goes-Here";

    // 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("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
    $result = json_decode($result);
    //use data here

Source: http://blueprintinteractive.com/blog/how-instagram-api-fancybox-simplified

Upvotes: 2

Related Questions