We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: tessed at Oct 10, 2015, 08:02 AM
    I don't remember, I removed everything.

    Question: shouldn't the script have an access token variable for recent media??
    Yes, as I remember. All queries for Instagram depend on token.
      • 29540
      • 58 Posts
      Its working now. The client's profile was set to private.

      The Russian site i saw must have been a default or something.
        • 9995
        • 1,613 Posts
        Would love to see this working on Evolution.

        I'm getting:
        Error : 
        file_get_contents(https://api.instagram.com/v1/users/my-insta-name/media/recent/?client_id=9e8d7d18608a46c396640b8ed58axxxd&count=10): 
        failed to open stream: HTTP request failed! HTTP/1.1 404 NOT FOUND
          Evolution user, I like the back-end speed and simplicity smiley
          • 36830
          • 140 Posts
          Thanks so much for this. How would you go about getting the caption for the image with this snippet?
            • 17667
            • 108 Posts
            I was not able to get a response with just a client ID, an access token was required. I found a fairly painless way to get my client ID (remember we need the numeric client ID) and an access token from the tutorial here:
            https://blueprintinteractive.com/blog/how-instagram-api-fancybox-simplified

            It had an automated generator for both.

            You can then modify the snippet InstaRecentMedia to:
            <?php
            $json = file_get_contents('https://api.instagram.com/v1/users/'. $user_id .'/media/recent/?access_token=' . $access_token . '&count=' . $count);
            $decode = json_decode($json, true);
            $output = '';
            foreach ($decode['data'] as $post) {
                $output .= $modx->getChunk($tpl,
                    array(
                        'link'      => $post['link'],
                        'image'     => $post['images']['standard_resolution']['url'],
                        'thumbnail' => $post['images']['thumbnail']['url'],
                        'comments'  => $post['comments']['count'],
                        'likes'     => $post['likes']['count'],
                        'caption'   => $post['caption']['text']
                    )
                );
            }
            return $output;


            And in your document use:
            [[!InstaRecentMedia?
              &user_id=`_NUMERIC USER ID_`
              &access_token=`_YOUR ACCESS TOKEN_`
              &count=`_HOW MANY ARTICLE WE WANT TO GET_`
              &tpl=`tpl.InstaRecentMedia`
            ]]
              • 53255
              • 6 Posts
              I can't get anything to display. I tested with my https://api.instagram.com/v1/users/*****/media/recent/?access_token=2******&count=6 and it posts back data but nothing in modx.