I build a instagram widget in my wordpress theme. And now I want to do a website demo, I want to display some ins feeds of famous instagram authors with my access token. But it seems that I can only display my own instagram feeds with my access token and user id. why? is ins change its API? I saw some author at themeforest can still display different instagram feed of famous ins authors. Could you teach me how to do that?
2 Answers
To the first question. Yes, Instagram restricted access
Every new app created on the Instagram Platform starts in Sandbox mode. Apps in this mode can use any API endpoint but are restricted to a limited number of users and media. This is great for developing and testing your app.
To go Live and fully access Instagram content, you will need to submit your application for review and approval. Once reviewed, you will only be able to request users the Permission Scopes for which your app was approved. Because of this, your application may not be able to use some API endpoints unless the corresponding permissions were reviewed and approved.
But you can get feeds making calls to web-version with ?__a=1 parameter. In this case you recieve json. You need to write some code:
$otherPage = 'nasa';
$profileUrl = "https://www.instagram.com/$otherPage/?__a=1";
$iterationUrl = $profileUrl;
$tryNext = true;
$limit = 100;
$found = 0;
while ($tryNext) {
$tryNext = false;
$response = file_get_contents($iterationUrl);
if ($response === false) {
break;
}
$data = json_decode($response, true);
if ($data === null) {
break;
}
$media = $data['user']['media'];
$found += count($media['nodes']);
var_dump($media['nodes']);
if ($media['page_info']['has_next_page'] && $found < $limit) {
$iterationUrl = $profileUrl . '&max_id=' . $media['page_info']['end_cursor'];
$tryNext = true;
}
}
If you need only 12 media from one feed, your code can be simplier (without while). In both cases use $media to save a feed in your storage, then display it on your pages.
Please go through the instagram feed wordpress plugin https://wordpress.org/plugins/evm-social-gallery/, For instagram feed for wordpress website.