如何链接到您在Tumblr的最新帖子?

时间:2012-10-02 17:53:02

标签: javascript php html tumblr

  

可能重复:
  How to display a link to my latest Tumblr post using Javascript?

有没有办法让我链接到我在tumblr上的最新帖子,请记住每次创建新帖子时URL都会更改?我检查了API,我很难尝试编写链接。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

只需阅读你的tumblr rss feed(即用php)并使用第一项的链接。 即。 “nationalpost”的tumblr rss feed的网址如下所示:

http://nationalpost.tumblr.com/rss

xml api也为你的最新帖子

提供了网址
http://nationalpost.tumblr.com/api/read

也可以作为json使用,所以你可以使用javascript

http://nationalpost.tumblr.com/api/read/json

使用jQuery可能看起来像这样:

$(document).ready(function() {
    $.getJSON('http://nationalpost.tumblr.com/api/read/json?callback=?', function(result) {
        $('#link').html('<a href="'+ result.posts[0].url +'">Latest Post</a>');
    });
});

这是working example on jsfiddle