This is the first time I'm trying to develop a facebook app so sorry in advance if my question is too naive.
What I n开发者_JAVA百科eed to do is making a chat-like facebook application where:
- the user can write something on the wall
- the app should be able to detect this event and send an HTTP request to an external web service of my own which will provide a response (text)
- publish that text as a comment
- the user should be able to continue the dialog by entering another comment(s) (in which case we go back to step #2)
Basically, this would be very similar to: https://www.facebook.com/SkyscannerFlightSearch
I think one (ugly) way to do this would be making a script which searches for new wall entries/comments and posts replies in an infinite loop by using the Graph API but it's obviously sub-optimal and expensive.
Is there any way to have facebook call a certain url every time a wall post/comment is entered? Or maybe something like Twitter's streaming API based on long-polling technique? Am I in the right direction by assuming such kind of solutions or I'm totally missing the point?
Thanks in advance.
Giampaolo
I am working on something very similar myself.
So far i have the "loop" which can be set to any page, group or app on facebook.
SAMPLE: https://shawnsspace.com/plugins/wallfeed.php My page wall. SAMPLE: https://shawnsspace.com/plugins/wallfeed.php?pageid=19292868552&ptype=feed&limit=40 Facebook Platform Wall.
With some perms, a form and user access_tokens i can make the wall postable. Asper UGLY - you do not need to run this in a loop, Facebook supports realtime updates and will send a response to your app when a user, or page has made a change.
MORE: http://developers.facebook.com/docs/api/realtime
Thanks for the input. I tried to use the real-time API by using object=user and fields=feed. If I understood the doc correctly this should result in my callback url being called (POST) every time a user writes something on my app's wall.
I received the initial GET request but never POST. This is the current configuration:
{
"data": [
{
"object": "user",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"feed"
],
"active": true
},
{
"object": "page",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"picture"
],
"active": true
}
]
}
I've noticed various user comments reporting different concerns about the reliability of this API. Also, here: http://developers.facebook.com/docs/reference/api/page/ it says: "Note: Real-time updates are not yet supported for the total number of Page checkins." ...which I'm not sure what it means exactly.
For the record, my app's page I'm using for tests is: http://www.facebook.com/pages/testgiamp/187148861354102?sk=wall
精彩评论