Is there a way to pull an instagram feed with PHP without logging in?

前端 未结 3 1629
迷失自我
迷失自我 2021-02-04 19:40

It seems that this solution no longer works -

How to get a user's Instagram feed

The new API requires an access token which is dynamically assigned after pas

3条回答
  •  温柔的废话
    2021-02-04 20:06

    We can still access the photos. But just last 12 photo. If want more photos access_token require. This my way to get photos.

    $instaResult = file_get_contents('https://www.instagram.com/'.$username.'/?__a=1');
    $insta = json_decode($instaResult);
    $instagram_photos = $insta->graphql->user->edge_owner_to_timeline_media->edges;
    

    Now we get the last photos array.

    Than i used in the view with foreach loop.

      @foreach($instagram_photos as $instagram_photo)
    • @endforeach

提交回复
热议问题