Facebook recently changes its Instagram API. Now I can get all the media
ids by requesting from this endpoint-
https://graph.facebook.com/v7.0/{ig-user-id}/media?access_token=...
But it only returns the media Ids, not any other media information such as caption
, media_url
, comments_count
, likes_count
etc.
For getting these data, I have to request from the API-
https://graph.facebook.com/v7.0/{ig-media-id}?fields=caption,media_url,comments_count&access_token=...
This is working well but the problem is I have to hit this API for each and every {ig-media-id}
which is not a good thing.
So, is there any way to get all the media with information (caption
, media_url
, comments_count
, likes_count
) by one API request like-
https://graph.facebook.com/v7.0/{ig-user-id}/media?fields=caption,media_url&access_token=...
Advertisement
Answer
I solve the problem using Nested Request. Special thanks to @Cbroe.
I’ve gained the result by using one query after changing the 1st API like this-
https://graph.facebook.com/v7.0/{ig-user-id}?fields=media.limit(4){id,caption,media_url}&access_token=...