loading

I got an email awhile back saying that the Pi Zero was back in stock at $5, so I brought one. When it arrived I set it up, poked around for a minute then threw it in a draw for a month as, though you can do a lot of things with a $5 computer, I'm not a very creative person (and they're all kinda of boring).

Then one day someone poked me on Facebook and I wish that I had thanked them earnestly for giving purpose to my five dollars, but I ended up making this Facebook auto re-poke server to endlessly torture them instead.

Seriously now, I thought it would be fun to write a little python script that automatically pokes someone back, but I didn't want to leave my PC running 24/7, and any free AWS server was in a different country so that Facebook was convinced I was hacked. In the end I realized I could just set the script running on my Pi Zero over wifi and forget about it, so that's what I did.

What you need:

  • The code
  • Something to run it on

You don't need a Raspberry Pi for this to work, anything with an internet connection that can run python scripts will do fine. I just wanted to be the 'cool' guy who replies in 30 seconds when someone pokes me at 4 am.

Step 1: The Code

The code is written to use Python 2 (default on Pi).

This code isn't written to be perfect (storing passwords in plain text is a bad idea, but I am too lazy to enter info on start each time), but it's only meant to be a fun little project in the first place. That being said if you do have any code suggestions, feel free to leave them on the comments, or even do it yourself in the repository.

Basically the code:

  • Logs in at m.facebook.com with the login data.
  • Reads the HTML for new pokes at m.facebook.com/pokes
  • Gets the "Poke Back" URL from each new poke and submits it

I've commented the code and I encourage reading it before giving it your login info. If you got the code from the Git repository, make sure the URL's still point to "m.facebook.com" as I'm not certain I've got the permissions right yet (Git is pretty spooky).

https://github.com/HobbsJacob/piPoker

I'll attach the code to this instructable as well, though it will likely become out of date.

Step 2: Set Up

Here's how to set up the code on a Raspberry Pi. If you know what you're doing you can probably skip this.

Boot up the Pi and make sure it has an internet connection, then copy the file to the Pi (via USB or from Git). To set up the file (see picture), open it in a text editor and change the login info to match your own. You can also change the frequency at which it checks for new pokes, and the maximum amount of new pokes to accept before giving an error (for not poking everyone under "Recommended Pokes" if Facebook updates).

Open a terminal then enter:

//Don't enter this - Use these lines once to set up
sudo apt get install python-pip
sudo pip install mechanize
sudo pip install beautifulsoup4

//Then use this to start it
cd DIRECTORY		//The location of poker.py e.g. Desktop
python poker.py

That's it, the program should print the names of the users it pokes to the terminal.

Thanks for reading and have fun making your friends think you have no life.

About This Instructable

782views

13favorites

License:

Bio: Don't diss the username, I made it when I was 12. I'm still 12 really.
More by oldladygran:Pi Zero Facebook Poke Server NOT a Facebook Hack 
Add instructable to: