Created
July 18, 2015 16:46
-
-
Save samkeeleyong/51b1b9cbb27c36e5173a to your computer and use it in GitHub Desktop.
Find a Facebook post from a long long time ago. (May not be efficient, but does the job. ;D )
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
import requests | |
my_user_id = "123456789012345" | |
keyword = " ara " | |
url = "https://graph.facebook.com/" + my_user_id + "/feed" | |
params = dict( | |
access_token = "ADD_REALLY_LONG_ACCESS_TOKEN_HERE" | |
fields = "id,message" | |
) | |
response = requests.get(url=url, params=params).json() | |
while(True): | |
posts = response["data"] | |
for post in posts: | |
if "message" in post: | |
if keyword in post["message"].lower(): | |
print post["id"] | |
print post["message"] | |
next_page = response["paging"]["next"] | |
response = requests.get(next_page).json() | |
print "next page" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment