如何在尝试从 Facebook 删除帖子之前检查帖子是否存在
希望你能帮助我解决我遇到的一些问题。
我正在编写一个 Facebook 应用程序,在其中使用 PHP SDK 向用户墙发布帖子以更新游戏得分。
我想做的是在发布新帖子之前删除旧帖子,这没问题。问题开始的地方是用户是否事先手动删除了旧帖子。在这种情况下,用户的 FB 会话将被丢弃,并且与 API 的所有交互都将变得不可能,直到用户再次进行 FB.login。
我使用的代码是:
try {
$statusUpdate = $facebook->api('/'.$postID, 'delete');
} catch (FacebookApiException $e) {
d($e);
}
如果帖子事先存在,则效果很好。
我想知道是否有可能这样做,以便如果删除调用失败,它不会删除会话,而只是返回一个我可以处理的错误,或者在调用删除函数之前检查帖子是否存在?
如果可以避免的话,我宁愿不向用户请求在publish_stream之上的read_stream权限。
hope you can help me with a bit of a problem I've encountered.
I'm writing a Facebook application where I'm making posts to user walls to update game score using the PHP SDK.
What I'm trying to do is delete the old post before posting the new one, and that's no problem. Where the problem starts is if the user has manually deleted the old post beforehand. When that's the case, the user's FB session is dropped and all interaction with the API becomes impossible until the user has gone through FB.login again.
The code I'm using is:
try {
$statusUpdate = $facebook->api('/'.$postID, 'delete');
} catch (FacebookApiException $e) {
d($e);
}
Which works fine if the post exists beforehand.
What I'm wondering is if there's a possibility to do this so that if the delete call fails, it doesn't drop the session and just returns an error that I can handle, or check if the post exists before calling the delete function?
I'd rather not ask users for read_stream permissions on top of publish_stream if I can avoid it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样:
如果帖子不存在,它将返回空结果。
请注意,
USERID_POSTID
是您的$postID
。How about something like:
If the post doesn't exists it would return an empty result.
Please note that
USERID_POSTID
is your$postID
.