简体   繁体   English

适用于Android的Facebook SDK:当我的Android应用发布的帖子“喜欢/评论”时,尝试获取通知

[英]Facebook SDK for Android: Trying to get a notification when one “likes/comment” the post made by my Android app

I'm fairly new to Facebook SFD for Android. 我是Android的Facebook SFD的新手。

What I'm trying to achieve is an Android app that uses facebook login, post to the user timeline and gets notified whenever one is commenting or liking that post. 我要实现的是一个使用Facebook登录,发布到用户时间轴并在有人评论或喜欢该帖子时得到通知的Android应用。

I went thru Facebook tutorials for login and for Publish to Feed. 我浏览了Facebook教程以进行登录和发布到Feed。 All went well. 一切顺利。

Now I'm struggling with the last part. 现在我在为最后一部分而苦苦挣扎。 I don't see how to be notified whenever there is a like or comments. 如果有喜欢或评论,我看不到如何收到通知。 I browsed the web and stackoverflow forum without any success. 我浏览了Web和stackoverflow论坛,但没有成功。 I'm guessing that there is a mechanism to be notified by Facebook and that I don't have to start a process just to monitor the post... 我猜想有一种机制可以通过Facebook通知,并且我不必启动过程来监视帖子...
Anyone could give me a hint on the API to use? 有人可以给我提示要使用的API吗?

I'm currently looking at "Creating Object Types" section Associating Actions with Object Creation ( https://developers.facebook.com/docs/opengraph/creating-object-types ) but it looks like this describes how to do for facebook web app, and not for android app. 我目前正在查看“创建对象类型”部分,将操作与对象创建相关联( https://developers.facebook.com/docs/opengraph/creating-object-types ),但它看起来像这样描述了如何对Facebook网站进行操作应用,而不适用于android应用。

EDIT 编辑

I've found this https://developers.facebook.com/docs/graph-api/real-time-updates/ but not quite sure how to "translate" this into Android coding. 我已经找到了这个https://developers.facebook.com/docs/graph-api/real-time-updates/,但不太确定如何将其“翻译”为Android编码。 If anyone could help me with this, it would be greatly appreciated. 如果有人可以帮助我,将不胜感激。

I guess you have to create a page in php that will handle the responses from Facebook, it starts with a 我想您必须在php中创建一个页面来处理来自Facebook的响应,该页面以

  • GET response from Facebook that you retrieve with $_GET["name"] in php, and you have to send back a confirmation to Facebook to confirm that the connection works, and Facebook will send you the answer you want via Facebook的GET响应,您使用php中的$_GET["name"]进行了检索,您必须将确认发送回Facebook以确认连接正常,Facebook会通过以下方式向您发送所需的答案

  • a POST request ( $_POST["name"] ) (with a json object, containing the informations about the user in object for example, and the different updates in entry ). POST请求( $_POST["name"]具有JSON对象,包含关于在用户的信息object ,例如,和在不同的更新entry )。

You can put all these informations in a database, and when the user start your application, you can automatically connect him to a php script that check if the database has new informations for him. 您可以将所有这些信息放在数据库中,并且当用户启动您的应用程序时,您可以自动将他连接到php脚本,该脚本检查数据库是否为他提供了新信息。

(specifying who he is, with a user variable that he keeps in the memory of his device, and then you ask for informations from the database about this user ). (使用保存在设备内存中的user变量来指定他是谁,然后您从数据库中请求有关该user )。 I haven't tested, but it should work. 我还没有测试,但是应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM