Facebook Graph API - 删除喜欢

Facebook Graph API - delete like(Facebook Graph API - 删除喜欢)
本文介绍了Facebook Graph API - 删除喜欢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在用 PHP 为 Facebook 开发一个应用程序,其中一部分列出了用户的喜欢".我想在每个赞旁边添加一个链接,以便用户可以通过删除他们认为合适的位置来管理他们的赞.

I'm developing an app for Facebook in PHP, part of which lists the user's "likes". I would like to add a link next to each like so that the user can manage their likes by deleting them where they see fit.

Facebook 在他们的图形 API 文档中提到了这一点:

Facebook mentions this in their graph api docs:

您可以通过向/POST_ID/likes 发出 DELETE 请求来删除赞(因为赞没有 ID).

You can delete a like by issuing a DELETE request to /POST_ID/likes (since likes don't have an ID).

但是每个赞都必须有一个 id——否则你会如何删除它?

But each like must have an id - how else would you delete it?

以前有人这样做过吗?

推荐答案

是的,喜欢在 Graph API 中没有 ID.您通过向 {item_id}/likes 发布或删除来喜欢或不喜欢某个项目,其中 {item_id} 被您喜欢/不喜欢的对象的 ID 替换.

Yes, likes don't have an ID in the Graph API. You like or unlike an item by POSTing or DELETEing to {item_id}/likes, where {item_id} is replaced by the ID of the object you're liking/unliking.

要了解当前用户喜欢什么(以便您可以适当地删除它们),您可以使用用户对象的喜欢"连接(文档).因此,如果您请求 http://graph.facebook.com/me/likes,您将获得用户喜欢的页面/人员/任何内容的列表.(注意:这不包括帖子或照片或类似的东西)

To find out what the current user has liked (so you can delete them appropriately), you can use the "likes" connection of the User object (docs). So, if you request http://graph.facebook.com/me/likes, you'll get a list of pages/people/whatever that a user has liked. (Note: this does not include posts or photos or things like that)

这将返回一个包含如下项目的数据数组:

This will return an array of data full of items like this:

{
     "name": "Very Hungry Caterpillar",
     "category": "Artist",
     "id": "29956247793",
     "created_time": "2009-03-27T15:48:29+0000"
}

里面的ID不是之类的ID.它是用户点赞过的对象的 ID,所以要取消点赞,必须对 http://graph.facebook.com/29956247793/likes 进行 DELETE.

The ID in there is not the ID of the like. It is the ID of the object that the user has liked, so in order to un-like it, you have to make a DELETE to http://graph.facebook.com/29956247793/likes.

这篇关于Facebook Graph API - 删除喜欢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)