AutomaticStatic
AutomaticStatic

Reputation: 1749

Python: Facebook Graph API search by name

I know this is really simple, but I cannot figure it out. Trying to search for a user by name.

import facebook
graph = facebook.GraphAPI(token)
graph.request(#HAVING PROBLEMS)

from the documentation:

def request(self, path, args=None, post_args=None, files=None, method=None)

graph.request('/search') got that part. Response is no node specified.

If I try graph.request('/search', 'any string at all'), for example:

graph.request('/search', 'my name') #or
graph.request('/search', 'name=whatever')

I get:

File "C:\Python27\lib\site-packages\facebook.py", line 291, in request
    args["access_token"] = self.access_token
TypeError: 'str' object does not support item assignment

Upvotes: 0

Views: 3095

Answers (1)

Ivan Galeano
Ivan Galeano

Reputation: 34

It's working for me:

import facebook
token = 'my_token'
graph = facebook.GraphAPI(token)
data = graph.request('/search?q=someusernane&type=user')
print data

Upvotes: 1

Related Questions