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.

Revisions

  1. hectorromo revised this gist Dec 19, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions instagram_feed.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    <?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;
  2. hectorromo renamed this gist Dec 19, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. hectorromo created this gist Dec 19, 2020.
    11 changes: 11 additions & 0 deletions insta.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?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>';