Skip to content

Instantly share code, notes, and snippets.

@hectorromo
Last active December 19, 2020 12:00
Show Gist options
  • Save hectorromo/2b99f28026e7de93e3a7d5e9229c4c51 to your computer and use it in GitHub Desktop.
Save hectorromo/2b99f28026e7de93e3a7d5e9229c4c51 to your computer and use it in GitHub Desktop.
Access instagram feed.
<?php
// Code taken from this post https://vinkla.dev/blog/fetch-instagram-data-with-php
$response = file_get_contents('https://instagram.com/wearestrom/?__a=1');
$user = json_decode($response);
$media = $user->graphql->user->edge_owner_to_timeline_media->edges;
// Displays latest post in feed.
echo '<a href="https://instagram.com/p/'. $media[0]->node->shortcode .'">';
echo '<img src="'. $media[0]->node->display_url .'" />';
echo '<p>'. $media[0]->node->edge_media_to_caption->edges[0]->node->text .'</p>';
echo '</a>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment