Tumblr API:有没有一种方法可以获取Tumblr帖子收到的喜欢数?

7

我正在编写一个 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的解决方案。

1
很遗憾,这是不可能的。note_count 是赞和转发的组合:http://tumblr.com/docs/en/api/v2#posts - mikedidthis
可能重复:http://stackoverflow.com/questions/29820031/how-to-get-individual-tumblr-posts-likes-count-for-tumblr-client-gem - mikedidthis
2个回答

2
如果有人在原帖发布2年后仍在寻找此功能......您可以通过将&notes_info=true 添加到您的api调用中来实现 - 将返回一组notes对象。如果您遍历这些对象,就可以计算出帖子类型的数量。据我所见,帖子类型有:posted(原始帖子),likereblog。希望这可以帮助您!

json响应中的示例注释集合:(仅显示1个注释)

'notes': [{'avatar_shape': 'square',
           'blog_name': 'xxx',
           'blog_url': 'xxx',
           'blog_uuid': 'xxx',
           'followed': False,
           'timestamp': 1505922448,
           'type': 'like'}],

重博客转载的内容而言,笔记列表不是都一样吗?如果我转载了一张有1000个笔记的照片,然后在我的转载帖子上调用API方法,那么我会看到1000个笔记,而无法知道哪些点赞是给我的转载帖子的,哪些是给原始帖子的。我错了吗? - Nakilon

1
似乎对于Tumblr API v2文档,是不可能的。你只能获得总博客点赞数或人们喜欢的帖子数的计数。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接