griimnak
You're a slave to the money then you die
In this tutorial i'll be showing you how to use facebook's graphAPI in python.
Pre-requisites:
unzip it to your desktop, then launch a terminal session and cd into your facebook api directory
then run the python instal script
Now we can delete that facebook folder and start our script.
create a new folder and use your desired text editor and save a .py file into it.
Now we can start our script, we'll make an auto-liking script for starters.
we begin by importing our api library that we installed earlier, you will see this alot in python as you need certain librarys to do certain functions that are not availible in python by default. Think of these librarys as python code plugins
now we need to generate a token to allow our desired facebook account to use this api and perform tasks,
then copy your access token and place it in our token variable
now we can specify the page that we want to auto like, and specify what object we are going to be touching, in this case the posts.
Now we make a simple loop, like each post that is outputed from our graph.get_connections query.
Here's the whole script:
now open a new terminal session again and run the file with this command:
that's as simple as it gets.
check out theses references to do more cool stuff with this api:
cheers
Pre-requisites:
- python 2.7:
You must be registered for see links
You must be registered for see links
unzip it to your desktop, then launch a terminal session and cd into your facebook api directory
then run the python instal script
Code:
python setup.py install
Now we can delete that facebook folder and start our script.
create a new folder and use your desired text editor and save a .py file into it.
Now we can start our script, we'll make an auto-liking script for starters.
we begin by importing our api library that we installed earlier, you will see this alot in python as you need certain librarys to do certain functions that are not availible in python by default. Think of these librarys as python code plugins
Code:
import facebook
now we need to generate a token to allow our desired facebook account to use this api and perform tasks,
You must be registered for see links
then copy your access token and place it in our token variable
Code:
token = "your_token_here"
now we can specify the page that we want to auto like, and specify what object we are going to be touching, in this case the posts.
Code:
profile = graph.get_object("sharefast")
posts = graph.get_connections(profile['id'], "posts")
Now we make a simple loop, like each post that is outputed from our graph.get_connections query.
Code:
for post in posts['data']:
try:
graph.put_object(post['id'], "likes")
print "liking topic: " + post['message']
except:
continue
Here's the whole script:
Code:
import facebook
token = "token here"
graph = facebook.GraphAPI(token)
profile = graph.get_object("sharefast")
posts = graph.get_connections(profile['id'], "posts")
for post in posts['data']:
try:
graph.put_object(post['id'], "likes")
print "liking topic: " + post['message']
except:
continue
now open a new terminal session again and run the file with this command:
Code:
python yourfile.py
that's as simple as it gets.
check out theses references to do more cool stuff with this api:
You must be registered for see links
You must be registered for see links
cheers