What is verify token in Facebook Realtime API

后端 未结 2 801
情深已故
情深已故 2021-01-21 15:05

I\'m trying to implement Facebook Realtime api with my application. I want to pull the feeds from my \'facebook PAGE\'. I\'ve obtained app_access_token...

app_ac         


        
相关标签:
2条回答
  • 2021-01-21 15:17

    Use POST rather than GET, with an empty body & object, fields, callback_url and verify_token passed as query parameters in the url.

    See https://developers.facebook.com/docs/reference/api/realtime/.

    0 讨论(0)
  • 2021-01-21 15:18

    I've figured this out... . . . . Make a POST request to url :

    'https://graph.facebook.com/' + FB_CLIENT_ID + '/subscriptions?access_token=' + app_access_token + '&object=page&fields=name&callback_url=' + YOUR_CALLBACK_URL + '&verify_token=' + ANY_RANDOM_STRING + '&method=post'
    

    Pass {} as post parameters..... Make sure that your_callback_url should be reachable. It will not work on localhost(I guess so... I was not able test it on localhost.)

    So in Python the code should be :

    url = 'https://graph.facebook.com/' + FB_CLIENT_ID + '/subscriptions?access_token=' + app_access_token + '&object=page&fields=name&callback_url=' + YOUR_CALLBACK_URL + '&verify_token=' + ANY_RANDOM_STRING + '&method=post'
    
    url_params = {}
    
    urlResponse = urllib2.urlopen(url, urllib.urlencode(url_params), timeout=socket.getdefaulttimeout()).read()
    

    urlResponse should be null.

    Function attached with callback_url should return:

    def callback_function(request):
       if request.GET: #(Handle this properly!!!)
           return request.GET.get('hub.challenge') #hub_challenge for PHP Developers. :)
    

    Please let me know in case of any doubts!!!

    To know how to handle notifications from the FB: Kindly visit the following URL: Handling notifications request from Facebook after successful subscription

    0 讨论(0)
提交回复
热议问题