3
votes

I have been using the below link for quite a while to search for Facebook applications on the graph API. See below link, searching for applications with the word "bingo" in it.

https://graph.facebook.com/search?type=application&q=bingo

Everything worked fine till the 10th of July, when Facebook made changes, see below text found on https://developers.facebook.com/docs/reference/api/search/#access_tokens:

The Graph API Search interface has changes pending with the Q3 2013 migration. Please see the blog post for more information on what's changed. Changes listed in the blog post will go live on July 10th, 2013.

Now, I tried to follow examples on https://developers.facebook.com/docs/reference/api/search/#access_tokens to get an application access token and append access_token= to the link above (https://graph.facebook.com/search?type=application&q=bingo) but I am still getting the same response from Facebook graph:

{
   "error": {
      "message": "(#200) Must have a valid access_token to access this endpoint",
      "type": "OAuthException",
      "code": 200
   }
}

Does anyone know how to work this around?

1

1 Answers

0
votes

you have to encode your access token into the http header of your request. With the Facebook 1.1 API, the usage of oauth2 lib for python is recommended.

import oauth2 
import urllib

access_token_key = "Your token key"
access_token_secret = "Your token secret"

consumer_key = "Your consumer key"
consumer_secret = "Your consumer secret"


oauth_token    = oauth.Token(key=access_token_key, secret=access_token_secret)
oauth_consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)


req = oauth2.Request.from_consumer_and_token(oauth_consumer,
                                             token=oauth_token,
                                             http_method=http_method,
                                             http_url=url, 
                                             parameters=parameters)

req.sign_request(signature_method_hmac_sha1, oauth_consumer, oauth_token)

  headers = req.to_header()

  if http_method == "POST":
    encoded_post_data = req.to_postdata()
  else:
    encoded_post_data = None
    url = req.to_url()


urllib.urlopen(url, encoded_post_data)

To get your oauth tokens and secrets, you need to define and register your application with twitter. (http://developers.twitter.com)

Best regards, Dave