Facebook Insights Date Error

1,029 views
Skip to first unread message

Human

unread,
Apr 10, 2014, 11:08:30 PM4/10/14
to pythonfo...@googlegroups.com
Whenever I try to query anything by a UNIX datetime in Python, it gives me this error: GraphAPIError: (#100) Must be a unixtime or a date/time representation parseable by strtotime()

When I do the same query in the Graph Explorer, I get the intended result.

Here is my query:  "/PAGE_NAME/insights/page_fan_adds?limit=10&until=1391848971&since=1391244171"

What is wrong?

Human

unread,
Apr 10, 2014, 11:30:14 PM4/10/14
to pythonfo...@googlegroups.com
Also, the query above works on the facepy package...but I really want it to work for this one.

Martey Dodoo

unread,
Apr 10, 2014, 11:47:34 PM4/10/14
to pythonfo...@googlegroups.com
Could you provide a short snippet of code that would trigger this error?

It would also help if you could provide details about what version of the SDK
and Python you are using.
> --
> You received this message because you are subscribed to the Google Groups "PythonForFacebook" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfaceb...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Human

unread,
Apr 11, 2014, 12:19:06 AM4/11/14
to pythonfo...@googlegroups.com
Sure thing.

The SDK version is 0.4.0
Python is 2.7.5 anaconda 

import facebook # pip install facebook-sdk
import json

# Create a connection to the Graph API with your access token
g = facebook.GraphAPI("TOKEN_ACCESS")

def pp(o): 
    print json.dumps(o, indent=1)

pp(g.get_object("/PAGE_NAME/insights/page_fan_adds?since=1391244171&until=1391848971"))

Martey Dodoo

unread,
Apr 11, 2014, 1:03:10 AM4/11/14
to pythonfo...@googlegroups.com
Can you try:

> g.get_object(
> "/PAGE_NAME/insights/page_fan_adds",
> since=1391244171,
> until=1391848971)

If you need to add items to a query string with the SDK, you need to use *args
or **kwargs (depending on the method) - they are escaped and converted in the
"request" method.
> > an email to pythonforfaceb...@googlegroups.com <javascript:>.

Human

unread,
Apr 11, 2014, 8:07:20 AM4/11/14
to pythonfo...@googlegroups.com
This worked. Thanks.

Additional question: Does Facebook-SDK package have anything that handles pagination to the next page of results?

Mitchell Stewart

unread,
Apr 12, 2014, 9:03:00 PM4/12/14
to pythonfo...@googlegroups.com
I don't think there is a canonical way of doing this with the package at the moment.
Reply all
Reply to author
Forward
0 new messages