[英]Pulling in an Instagram feed of image to my website
我正在使用一些JS通过与图片相关的特定标签从我的帐户中提取Instagram图片的供稿。
我已将其设置为拉入10张图像,但由于某种原因,它似乎拉入了21张图像。
几天前这还可以,但是突然之间现在不起作用,也不知道为什么
这是在线页面http://www.gezzamondo.co.uk/simple.html
// JavaScript Document
$(function() {
var cmdURL, embedImage, onPhotoLoaded, param, tag_name, userid,
param = {
access_token: "I'VE REMOVED THIS", // feel free to change it with your own access token
count: 10 // the total number of images
},
tag = 'Gezzamondoportfolio', // your user id. you can find this one out by looking into one of your pictures uri
tag_name = '#photowall',
cmdURL = 'https://api.instagram.com/v1/tags/' + tag + '/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);
});
尝试将count参数添加到您的请求URL中:
cmdURL = 'https://api.instagram.com/v1/tags/' + tag + '/media/recent?count=10&callback=?';
(编辑)在创建照片的for循环中,您也只能计数到10:
for (_i = 0, _len < 10; _i < _len; _i++) {
photo = _ref[_i];
_results.push(embedImage(photo));}
显然,这不会改变您从Instagram返回的结果数量,但会限制您输出到屏幕上的结果数量...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.