如何获取热门帖子的 Dribbble feed?

问题描述 投票:0回答:1

我尝试在网站上提供 Dribbble feed,其中包含最新的热门帖子。我不确定是否应该通过以下方式注册应用程序:https://dribbble.com/account/applications/new 或者我可以使用 JSON 或 AJAX 来提取 Dribbble 上发布的最新照片吗?

我已经尝试过这个,但没有成功。我收到错误:

错误:

GET https://api.dribbble.com/shots/popular?callback=jQuery111104258300690995278_1471442725999&_=1471442726000 404 (Not Found)

JS:

$.getJSON("http://api.dribbble.com/shots/popular?callback=?", function(data) {
    console.log(data);
    $('.dribbble-feed').append('<img src="' + data.shots[0].image_url + '" />');
});

演示:http://codepen.io/anon/pen/YWgLaR?editors=1111

更新

按照 Karol Klepacki 给出的答复后,当我将数据记录到控制台时,我收到以下信息:

更新了JS:

$.getJSON("https://api.dribbble.com/v1/shots/popular?callback=?", function(data) {
    console.log(data);
    $('.dribbble-feed').append('<img src="' + data.shots[0].image_url + '" />');
});
javascript jquery getjson dribbble-api
1个回答
1
投票

dribble api 的正确地址是

https://api.dribbble.com/v1/shots

现在您必须验证自己的身份。您必须注册应用程序,并且您可能会获得一些令牌,您必须将其附加到您的请求中(方法2从这里对您来说应该更容易。然后您将收到类似

https://api.dribbble.com/v1/shots/?access_token=TOKEN

的请求
$(document).ready(function() {

  $.getJSON("https://api.dribbble.com/v1/shots/?access_token=TOKEN", function(data) {
    data.forEach(function(e){
      $('.dribbble-feed').append('<img src="' + e.images.normal + '" />');
    })
  });
});
© www.soinside.com 2019 - 2024. All rights reserved.