问题
I'm trying to implement Facebook Real Time Update in a proper manner. (https://developers.facebook.com/docs/reference/api/realtime/).
Everything is done according to the instructions given in this page, but the returned JSON from Facebook is missing interesting information.
The JSON is for example:
{"object":"user","entry":[{"uid":"1408932149","id":"1408932149","time":1370253930,"changed_fields":["feed"]}]}
But the event that induced the event was a comment on a facebook-page. I want more information. For example the id of the post, id of the comment and similar vital information.
Why is Facebook only returning that the field "feed" changed and not the id of the comment?
Regards, Jonas
回答1:
Update: found this, sounds promising: http://allfacebook.com/page-posts-real-time-updates-api_b111225
I have the same problem. As far as I can tell, this is what FB's system was designed to do, even though we would really LIKE to get higher granularity information pushed (and it would likely be more efficient for FB's servers, since as it is now, developers may have to write code that digs through the feed to find the relevant comment or such, possibly fetching quite a lot of stuff we through away, just to get one comment).
Bummer. If anyone has any good ideas to offer, I'd be grateful. We want our app to react to certain comments on a user's wall, which we do already for the user's own status updates, but to do it for comments it looks like we would have to scrape the whole feed (which sounds impractical at scale), since the new comment could be on an old status update.
回答2:
The reason for this was fairly easy once I realised it.
It the Facebook developer page for pages (https://developers.facebook.com/docs/reference/api/page/#realtime). This question is the result if one only does step 1 and fails in doing step 2 and 3.
Having done that, and carefully using the access_token for the page, everything started working and now it works fine. Not really within the five seconds promised by Facebook, but good enough.
I have also found that using an a api such as Facebook SDK for .NET (http://facebooksdk.net/) can be very rewarding, but it might make it harder to understand the api presented by Facebook.
回答3:
You receives RTU from "Web hooks" - it is more simple feature.
If you want receive RTU with next format:
{"object":"page","entry":[{"id":"593349087454592","time":1445698004,"changes":[{"field":"feed","value":{"item":"post","verb":"add","post_id":"593349087454592_787861828003316","is_hidden":false,"sender_id":1442769135993502,"message":"Post #4","sender_name":"Sheva Che"}}]}]}
you should setup RTU with help of Graph API. Below you can see several examples of operations:
Hope it will be useful
来源:https://stackoverflow.com/questions/16894655/facebook-real-time-update-return-only-changed-fieldsfeed-and-not-the-actu