How to get images using Instagram API

后端 未结 2 1238
夕颜
夕颜 2021-01-06 06:48

How to get users images from Instagram API?

access_token=4049241557.1677ed0.5324ad17d9314645b528ad112da8d56e

But no success, it\

相关标签:
2条回答
  • 2021-01-06 07:02

    You could use this library Cosenary.

    use MetzWeb\Instagram\Instagram;
    
    $instagram = new Instagram(array(
        'apiKey'      => 'YOUR_APP_KEY',
        'apiSecret'   => 'YOUR_APP_SECRET',
        'apiCallback' => 'YOUR_APP_CALLBACK'
    ));
    
    // grab OAuth callback code
    $code = $_GET['code']; 
    // or maybe $code = $request->code; // if you are using Laravel
    $data = $instagram->getOAuthToken($code);
    
    // set user access token
    $instagram->setAccessToken($data);
    
    // and
    $pictures = $instagram->getUserMedia();
    

    Read the documentation for more information.

    Hope this helps.

    0 讨论(0)
  • 2021-01-06 07:05

    Use this API:

    https://api.instagram.com/v1/users/self/media/recent?access_token={access-token}
    

    This will get your photos,(but it looks like from the access_token you have posted, that user does not have any photos posted, so it will return empty array)

    Use this to get other user's photo:

    https://api.instagram.com/v1/users/{user-id}/media/recent?access_token={access-token}
    

    you should have authenticated with public_content scope and if you are in sandbox mode, only sandbox users can be accessed until your app is reviewed and live

    0 讨论(0)
提交回复
热议问题