【问题标题】:Instagram API with more than 20 images包含 20 多张图片的 Instagram API
【发布时间】:2016-12-28 10:45:59
【问题描述】:

我想问你,是否有可能使用 API 从 Instagram 获取 20 多张全分辨率图片。

<script type="text/javascript">
var feed = new Instafeed({
    get: 'user',
    userId: '2201292293',
    clientId: 'MY_CLIENT_ID',
    accessToken:`'MY_ACCESS_TOKEN',
    limit: '364',
    sortBy: 'most-liked',
    template: '<a href="{{image}}" class="popup"><img src="{{image}}"></a>{{likes}}',
    resolution: 'standard_resolution'
});
feed.run();

提前谢谢你,劳伦兹·斯特劳赫

【问题讨论】:

  • 请说的更具体一些,你用的是什么api?您使用哪个端点?你已经尝试了什么?应该有limit 之类的。
  • @JozefCipa 我使用 Instagram API (Instagram.com/developer)
  • @JozefCipa 我也使用 instafeed.js 在我的网站上显示它,我在那里写了“limit: 364”...
  • 真的有20多张图片吗?我不知道你真正想做什么。您想按用户或主题标签或如何获取图像?请也出示您的代码。
  • @JozefCipa 我网站的代码现在位于问题中。我想做的是:我希望 instafeed.js 在我的网站上显示我的帖子(用户),但 Instagram 只允许您发布 20 张图片。所以我想知道是否有可能展示超过 20 张图片。

标签: image api web instagram instagram-api


【解决方案1】:

可能是分页造成的。

添加

<button id="load-more">
  Load more
</button>

到您的 html。每次单击按钮时,feed.next() 都会被调用并获取更多图像(如果存在)。

<script type="text/javascript">
    var loadButton = document.getElementById('load-more');
    var feed = new Instafeed({
        get: 'user',
        userId: '2201292293',
        clientId: 'MY_CLIENT_ID',
        accessToken:`'MY_ACCESS_TOKEN',
        limit: '364',
        sortBy: 'most-liked',
        template: '<a href="{{image}}" class="popup"><img src="{{image}}"></a>{{likes}}',
        resolution: 'standard_resolution'

        // every time we load more, run this function
        after: function() {
            // disable button if no more results to load
            if (!this.hasNext()) {
                loadButton.setAttribute('disabled', 'disabled');
            }
        },
    });

    // bind the load more button
    loadButton.addEventListener('click', function() {
        feed.next();
    });

    // run our feed!
    feed.run();
</script>

试试这个代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-09
    • 2015-02-09
    • 2016-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多