我正在编写一个 PHP 应用程序,需要获取 Tumblr 帖子的点赞数。我使用 Tumblr PHP 库 并已成功验证等操作。我使用 Client::getBlogPosts()
获取帖子列表。它返回的是一个类似于 PHP 数组的信息,例如:
{
"blog_name": "jeteon",
"id": 92729317211,
"post_url": "http://jeteon.tumblr.com/post/92729317211/where-to-find-libxm-so-2-for-ubuntu",
"slug": "where-to-find-libxm-so-2-for-ubuntu",
"type": "link",
"date": "2014-07-24 13:43:04 GMT",
"timestamp": 1406209384,
"state": "published",
"format": "html",
"reblog_key": "oA2WcGac",
"tags": [
"dakota",
"ubuntu"
],
"short_url": "http://tmblr.co/Z9ROeu1MN6HTR",
"highlighted": [],
"note_count": 0,
"title": "Where to find libXm.so.2 for Ubuntu",
"url": "https://packages.debian.org/wheezy/lesstif2",
"author": null,
"excerpt": null,
"publisher": "packages.debian.org",
"description": "<p>I recently had to install Dakota (<a href=\"http://dakota.sandia.gov\">http://dakota.sandia.gov</a>) and after considerable trouble with prerequisites, found that the binary install on Ubuntu requires (amonst other umentioned libraries) a shared library called libXm.so.2. The library is in a package called lesstif2 which is no longer available, it seems. You can grab the DEB on the above link though.</p>",
"reblog": {
"tree_html": ""
},
"trail": [
{
"blog": {
"name": "jeteon",
"theme": {
"avatar_shape": "square",
"background_color": "#FAFAFA",
"body_font": "Helvetica Neue",
"header_bounds": "",
"header_image": "http://assets.tumblr.com/images/default_header/optica_pattern_10.png?_v=eafbfb1726b334d86841955ae7b9221c",
"header_image_focused": "http://assets.tumblr.com/images/default_header/optica_pattern_10_focused_v3.png?_v=eafbfb1726b334d86841955ae7b9221c",
"header_image_scaled": "http://assets.tumblr.com/images/default_header/optica_pattern_10_focused_v3.png?_v=eafbfb1726b334d86841955ae7b9221c",
"header_stretch": true,
"link_color": "#529ECC",
"show_avatar": true,
"show_description": true,
"show_header_image": true,
"show_title": true,
"title_color": "#444444",
"title_font": "Gibson",
"title_font_weight": "bold"
}
},
"post": {
"id": "92729317211"
},
"content": "<p>I recently had to install Dakota (<a href=\"http://dakota.sandia.gov\">http://dakota.sandia.gov</a>) and after considerable trouble with prerequisites, found that the binary install on Ubuntu requires (amonst other umentioned libraries) a shared library called libXm.so.2. The library is in a package called lesstif2 which is no longer available, it seems. You can grab the DEB on the above link though.</p>",
"is_root_item": true,
"is_current_item": true
}
]
}
我需要的最接近的字段是
note_count
,尽管这个字段包括了喜欢和转发两种情况。如果 note_count
是 0,那么就没有问题了,但是当笔记数为 41 时,我无法确定它是否被喜欢了 40 次并被转发一次或者相反。无论如何,liked
字段的存在或不存在已经告诉你这个信息。我尝试使用
Client::getBlogLikes()
方法,但是它检索到的是博客喜欢的帖子列表(在 Tumblr 的说法中,实际上是创建用户喜欢的帖子),这与我要找的相反。我从互联网上找到的最好答案是这篇文章,它建议使用 URL api.tumblr.com/v2/blog/{base-hostname}/likes?api_key={key},但据我所知从代码上看,这与使用Tumblr PHP库中的
Client::getBlogLikes()
函数是一样的。有人知道获取特定帖子收到的喜欢数量的方法吗?它不需要是针对PHP的解决方案。
note_count
是赞和转发的组合:http://tumblr.com/docs/en/api/v2#posts - mikedidthis