iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🔑

Alternative Token Generator for Instafeed.js

に公開

Problem

  • When I tried to use Instafeed.js to display Instagram images on my website, I found that the recommended Heroku package Instagram Token Agent was no longer usable because some of its features are now paid.

As mentioned in this issue.

Solution

  • Use a service called Instant Tokens to handle the token retrieval process.

Steps

1. Setting up the Instagram Basic Display API

  • Follow the steps in the API documentation up to Step 6 to ensure that you can retrieve an access token

2. Linking Instant Tokens with your Instagram account

  1. Access Instant Tokens and register an account
    Instant Tokens

  2. Link your Instagram account

  3. Open settings and obtain the JS file URL or the request destination URL

  4. Import Instafeed and the JS file for token retrieval

index.html
<!-- Instafeed -->
<script type="text/javascript" src="path/to/instafeed.min.js"></script>

<!-- token -->
<script type="text/javascript" src="https://ig.instant-tokens.com/users/{user_id}/instagram/{app_id}/token.js?userSecret={user_secret}"></script>
  1. Since the token is assigned to the variable name InstagramToken, use this to display the images
token
var InstagramToken = {access_token};
index.html
<div id="instafeed"></div>

<script type="text/javascript">
    var feed = new Instafeed({
      accessToken: InstagramToken
    });
    feed.run();
</script>
GitHubで編集を提案

Discussion