1

I am using Python facebook-sdk to fetch users's posts in Facebook page.

In facebook Graph api explorer, the request went well:

Get .../coldplay/feed?limit=2

enter image description here

In my program, the request:

In [27]: graph = facebook.GraphAPI("...")
In [28]: posts = graph.get_object('coldplay/feed?limit=2') 

report error:

GraphAPIError                             Traceback (most recent call last)

/home/ubuntu/<ipython console> in <module>()

/usr/local/lib/python2.7/dist-packages/facebook.pyc in get_object(self, id, **args)
     97     def get_object(self, id, **args):
     98         """Fetchs the given object from the graph."""
---> 99         return self.request(id, args)
    100
    101     def get_objects(self, ids, **args):

/usr/local/lib/python2.7/dist-packages/facebook.pyc in request(self, path, args, post_args)
    296         except urllib2.HTTPError, e:
    297             response = _parse_json(e.read())
--> 298             raise GraphAPIError(response)
    299         except TypeError:
    300             # Timeout support for Python <2.6

If I request without "?limit=2", the program works well:

In [45]: graph = facebook.GraphAPI("...")
In [46]: posts = graph.get_object('coldplay/feed')                                        
In [47]: len(posts)
Out[47]: 2

So I want to know how to make the request: '.../feed?limit=2' works well for the Python facebook-sdk? Thanks.

1 Answer 1

3

You should provide limit as an argument other than a part of the object.

The definition of get_object is def get_object(self, id, **args) which means you need to provide as keyword args

In your case: graph.get_object('coldplay/feed', limit=2)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.