Last active
December 19, 2020 12:00
-
-
Save hectorromo/2b99f28026e7de93e3a7d5e9229c4c51 to your computer and use it in GitHub Desktop.
Access instagram feed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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