Forked from deanmalmgren/facebook_post_rate_example.py
Last active
August 29, 2015 14:08
-
-
Save fatihky/1631d084332800995b45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This gist demonstrates how to automatically authenticate with Facebook's OAuth2 | |
using fbconsole --- programmatically, without a browser --- and then count the number | |
of Posts, for example, on a Facebook Page. | |
""" | |
import fbconsole | |
import datetime | |
import time | |
# set up fbconsole | |
fbconsole.APP_ID = "xxxx_your_app_id" | |
fbconsole.AUTH_SCOPE = ["read_stream",] | |
page_id = "xxxx_your_Page_id" | |
# use fbconsole's automatically_authenticate method | |
# to login to the server programmatically | |
fbconsole.automatically_authenticate( | |
"xxxx_your_username", | |
"xxxx_your_password", | |
"xxxx_your_redirect_uri", | |
) | |
# get all the Posts for last year | |
now = datetime.datetime.now() | |
last_year = now - datetime.timedelta(days=days) | |
opts = { | |
"since": str(int(time.mktime(last_year.timetuple()))), | |
} | |
result = fbconsole.get("/%s/posts" % page_id, opts) | |
print len(result["data"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment