【问题标题】:Pulling in most recent feed on instagram without using hashtag在不使用标签的情况下在 instagram 上提取最新的提要
【发布时间】:2023-04-02 14:40:01
【问题描述】:

我目前正在使用一些 javascript 从我搜索的主题标签中提取 6 张最近的图像。我想在不使用标签来搜索特定图像的情况下整体提取 6 张最近的图像。

我需要在这段代码中添加什么来从用户那里提取 6 张最近的图像而不是主题标签

  $(function() {
var cmdURL, embedImage, onPhotoLoaded, param, tag_name, userid,
param = {
access_token: 'xxxxxx', // feel free to change it with your own access token
count: 6 // the total number of images
},

userId = '11941870', tag = '', //你的用户ID。你可以通过查看你的一张照片 uri 找到这个 tag_name = '#photowall', cmdURL = 'https://api.instagram.com/v1/tags/' + 标签 + '/media/recent?callback=?';

 embedImage = function(photo) {
var a, img;
img = $('<img/>').attr({
  //'src': photo.images.thumbnail.url,
  //'width': photo.images.thumbnail.width,
  //'height': photo.images.thumbnail.height
  'src': photo.images.standard_resolution.url,
  'width': photo.images.standard_resolution.width,
  'height': photo.images.standard_resolution.height
});
a = $('<a />').attr({
  'href': photo.images.standard_resolution.url,
  'target': '_blank',
  'class': 'pull-left'
}).append(img).appendTo(tag_name);
    };

onPhotoLoaded = function(data) {
var photo, _i, _len, _ref, _results;
if (data.meta.code === 200 && data.data) {
  _ref = data.data;
  _results = [];
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    photo = _ref[_i];
    _results.push(embedImage(photo));
  }
  return _results;
}
};
return $.getJSON(cmdURL, param, onPhotoLoaded);
  });

【问题讨论】:

    标签: javascript instagram


    【解决方案1】:

    查看 Instagram Api 有这个调用

    https://api.instagram.com/v1/users/<user_id>/media/recent
    

    这将返回用户的最新照片。

    我想你可以在这里查看它是如何工作的 https://instagram.com/developer/api-console/

    【讨论】:

    • 我已经更新了上面的代码,表明我已经添加了 UserId 的代码,但现在似乎没有什么想要通过的。有什么建议吗?
    • 您的代码仍在使用标签 api url。它应该是 cmdURL = 'ht tps://api. instagram.com/v1/users/'+userId+'/media/recent?callback=?';
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-11
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多