Search This Blog

Thursday 24 December 2015

Auto Like and Auto Comment Facebook posts

Like and comment all the posts on Facebook(using python)

We will need following 2 things:
1. Access token
2. Object Id

Where to get this from????

Goto: 
developers.facebook.com->Tools and Support->GraphAPI Explorer

1. Copy access token
2. Click on submit
3. Copy id

Following is the auto-like and auto-comment script:

import facebook
import re
token = "Paste your access token over Here"
graph = facebook.GraphAPI(token)
#pages = ['rahuldravid']
profile = graph.get_object("Paste Your object Id")
posts = graph.get_connections(profile['id'],"posts") // this line would connect us to the facebook profile
for post in posts['data']:
        try:
            graph.put_object(post['id'],"likes") //this line would like all the posts of facebook
            graph.put_comment(post['id'],message="Long live rahul dravid") // I am going to comment "Long live rahul dravid"
            print "I am commenting :" +post["message"] // Just to check whether our script is working or not...Lets print message
        except:
            continue



// SAVE script with .py extension
//VIEW FOLLOWING VIDEO TO KNOW MORE:
https://www.youtube.com/watch?v=6xSLYgLvu0k





2 comments:

  1. help
    Traceback (most recent call last):
    File "C://PythonTest.py", line 1, in
    import facebook
    File "__init__.py", line 31, in
    ImportError: No module named requests

    ReplyDelete
  2. why do i get facebook has no graph api module

    ReplyDelete