【发布时间】: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