嘿,我使用了一些 API,但没有使用 Tumblr API,在阅读此页面后:http ://www.tumblr.com/docs/en/api/v2我很确定我了解如何设置它所以我会试着解释一下,如果你成功了,你可以告诉我
(删除代码,PHP API 很糟糕)
编辑:删除原始编辑
就因为 Tumblr PHP 客户端是垃圾,所以我自己看了一下,只是设计了一小段代码来解决这里的问题,并在一个数组中检索你的最新帖子,这会给你这样的:
Array
(
[0] => Array
(
[id] => 49867777007
[type] => photo
[description] =>
[date] => 2013-05-07 18:28:41 GMT
[short_url] => http://tmblr.co/Z5XfMxkSMUFl
[caption] =>
[photo_url] => http://31.media.tumblr.com/a13494fb3cda1e40ab39211973a094f9/tumblr_mm0038sZGH1qdlh1io1_400.gif
[width] => 395
[height] => 350
)
使用此代码,然后$myposts
在页面上稍后浏览
<?php
$apikey = "your_api_key";
$limit = 10;
$tumblr = "your.tumblr.com";
$apidata = json_decode(file_get_contents("http://api.tumblr.com/v2/blog/$tumblr/posts?api_key=$apikey&limit=$limit"));
$mypostsdata = $apidata->response->posts;
$myposts = array();
$i = 0;
foreach($mypostsdata as $postdata) {
$post['id'] = $postdata->id;
$post['type'] = $postdata->type;
$post['description'] = $postdata->description;
$post['date'] = $postdata->date;
$post['short_url'] = $postdata->short_url;
$post['caption'] = $postdata->caption;
$post["photo_url"] = $postdata->photos[0]->original_size->url;
$post["width"] = $postdata->photos[0]->original_size->width;
$post["height"] = $postdata->photos[0]->original_size->height;
$myposts[$i] = $post;
$i++;
}
// Then handle $myposts later on your page
echo '<pre>'.print_r($myposts).'</pre>';
// There's quite a lot more data you can use so if you want
// to print out $mypostsdata then you might find any more data you need
?>
抱歉,之前的建议不起作用,PHP 客户端真的很糟糕,但如果这足够了,或者您需要对其进行一些修改,请告诉我