如何获取热门帖子的 Dribbble 提要?
How to get Dribbble feed of popular posts?
我想在一个网站上创建一个包含最新热门帖子的 Dribbble 提要。我不确定我是否应该通过以下方式注册应用程序: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 + '" />');
});
运球 api 的正确地址是 https://api.dribbble.com/v1/shots
。
现在您必须验证自己的身份。你必须 register application, and you'll probably get some token, that you have to attach to your requests (Method 2 from here 对你来说应该更容易。然后你会收到类似 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 + '" />');
})
});
});
我想在一个网站上创建一个包含最新热门帖子的 Dribbble 提要。我不确定我是否应该通过以下方式注册应用程序: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 + '" />');
});
运球 api 的正确地址是 https://api.dribbble.com/v1/shots
。
现在您必须验证自己的身份。你必须 register application, and you'll probably get some token, that you have to attach to your requests (Method 2 from here 对你来说应该更容易。然后你会收到类似 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 + '" />');
})
});
});