开发者

Real-time Update

开发者 https://www.devze.com 2023-04-07 18:40 出处:网络
I really hope this is not a naive question but does Facebook real time upda开发者_如何学运维tes work on user\'s status updates? if so can someone point me in the right direction because I can\'t seem

I really hope this is not a naive question but does Facebook real time upda开发者_如何学运维tes work on user's status updates? if so can someone point me in the right direction because I can't seem to confirm this anywhere.


You can't subscribe to these user connections yet: home, tagged, posts, photos, albums, videos, groups, notes, events, inbox, outbox, updates, accounts

http://developers.facebook.com/docs/reference/api/realtime/


It's called long-polling. Look up node.js and long-polling ajax concepts.

Essentially the client makes an initial ajax request and waits for a response with no timeout set. Server-side JS will trigger an event when the user updates his/her status and send the response to any JS clients awaiting said response. The information gets updated, and immediately the client sends another request and waits for the next event.


You can subscribe to the 'feed' connection of your app users, which then also triggers on status updates.

    URL = 'https://graph.facebook.com/%s/subscriptions' % appid
    data = {'object': 'user',
            'fields': 'feed',
            'callback_url': callback,
            'verify_token': verify_token,   
            'access_token': access_token,    
    }
    res = requests.post(URL, params=data)
    print res.content
    print res.ok

The access_token must be an application access token, not a user access token. The above request will subscribe you to updates of all of your users! The message sent by the Facebook server will only include the user ID of the user, though, and no details about what happened. You have to figure that out yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号