Skip to content

Instantly share code, notes, and snippets.

@riyadparvez
Last active July 14, 2021 05:41
Show Gist options
  • Save riyadparvez/5942471 to your computer and use it in GitHub Desktop.
Save riyadparvez/5942471 to your computer and use it in GitHub Desktop.
This python script auto comment thanks on facebook wall posts
# Thanking everyone who wished me on my birthday
import requests
import json
from time import strftime
AFTER = #convert your time to iso 8601 time
TOKEN = ' <insert token here> '
def get_posts():
"""Returns dictionary of id, first names of people who posted on my wall
between start and end time"""
query = ("SELECT post_id, actor_id, message FROM stream WHERE "
"filter_key = 'others' AND source_id = me() AND "
"created_time > " + AFTER + " LIMIT 200")
payload = {'q': query, 'access_token': TOKEN}
r = requests.get('https://graph.facebook.com/fql', params=payload)
result = json.loads(r.text)
return result['data']
def commentall(wallposts):
"""Comments thank you on all posts"""
#TODO convert to batch request later
for wallpost in wallposts:
r = requests.get('https://graph.facebook.com/%s' %
wallpost['actor_id'])
url = 'https://graph.facebook.com/%s/comments' % wallpost['post_id']
user = json.loads(r.text)
message = 'Thanks %s :)' % user['first_name']
payload = {'access_token': TOKEN, 'message': message}
s = requests.post(url, data=payload)
print "Wall post %s done" % wallpost['post_id']
if __name__ == '__main__':
commentall(get_posts())
@CodeMaster1
Copy link

have you run this script? Is there a read me file for this?

@meetchandan
Copy link

what do you mean by token here?

@chrism91
Copy link

Token means; access token from Graph API, make sure to have Extended Permissions checked when using this.

@mustajabsaleemi25
Copy link

where to get token and is this script working waiting for your reply?

@owaisr814
Copy link

tell me something about time portion

@helloeliza
Copy link

nice

@AlexCalin
Copy link

AlexCalin commented Mar 7, 2018

I found a nice script that does everything automatically and have a lot of options like filters, anti spam feature etc. Also it sends private messages to all commentators :) https://www.fblikeinviter.com/en/#script2

@divyakrithi
Copy link

Great … it is very very helpful.
docker online training

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment