0

我一直在使用 instafeed.js 拉取 instagram 提要,我遵循了注册新应用程序的过程,因此我可以在拉取信息时对图片进行模板化。

我发现本教程可以有效地设置图像样式,因此我决定实现它:

var feed = new Instafeed({
  clientId: '877c13677a614436ad3d65856a9f4c8c',
  limit: 20,
  sortBy: 'most-liked',
  after: function () {
    var images = $("#instafeed").find('a');
    $.each(images, function(index, image) {
      var delay = (index * 75) + 'ms';
      $(image).css('-webkit-animation-delay', delay);
      $(image).css('-moz-animation-delay', delay);
      $(image).css('-ms-animation-delay', delay);
      $(image).css('-o-animation-delay', delay);
      $(image).css('animation-delay', delay);
      $(image).addClass('animated flipInX');
    });
  },
  template: '<a href="{{link}}" target="_blank"><img src="{{image}}" /><div class="likes">&hearts; {{likes}}</div></a>'
});
feed.run();

http://codepen.io/anon/pen/Bmhdp

但是当我更改客户端 ID 时,图像不是客户端的图像。

我对 instagram API 比较陌生,但我注意到它有点滞后,我也无法向他们报告这种情况..

我是不是做错了什么,请指教!

4

2 回答 2

0

Try adding the standard option "get". And depending on what you choose as get, you'll need to add the option for the that. So if you say:

get : 'tagged'

You'll have to add the tagName along with it. So something like

get : 'tagged',
tagName: 'anythingHastagYoulike'

That will pull photos by Hastag. If you want pull photos by a location, You'll do some thing like...

get : 'location',
locationId : 0000000;

Find the locations ID swap out the number. No quotes need for that.

So depending on what you are trying to pull from instagram, your 'get' will change and you'll need to add the appropriate endpoint for that. If you're just trying to pull an Instagram-wide image search by hashtag, you'll code might look something like this.

var feed = new Instafeed({
  clientId: '877c13677a614436ad3d65856a9f4c8c',
  limit: 20,
  get: 'tagged', // added
  tagName: 'anytag', // added
  sortBy: 'most-liked',
  after: function () {
  var images = $("#instafeed").find('a');
  $.each(images, function(index, image) {
  var delay = (index * 75) + 'ms';
  $(image).css('-webkit-animation-delay', delay);
  $(image).css('-moz-animation-delay', delay);
  $(image).css('-ms-animation-delay', delay);
  $(image).css('-o-animation-delay', delay);
  $(image).css('animation-delay', delay);
  $(image).addClass('animated flipInX');
});
},
      template: '<a href="{{link}}" target="_blank"><img src="{{image}}" />     <div class="likes">&hearts; {{likes}}</div></a>'
});
feed.run(); 
于 2015-01-18T15:17:01.210 回答
0

自己多加注意就找到了答案。

运行函数 feed.run() 的方法;应该是 userFeed.run();

于 2014-09-23T17:03:44.923 回答