Skip to content

Instantly share code, notes, and snippets.

@samkeeleyong
Created July 18, 2015 16:46
Show Gist options
  • Save samkeeleyong/51b1b9cbb27c36e5173a to your computer and use it in GitHub Desktop.
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 )
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