Nov 21, 2008

Automate birthday wishes on facebook

NEW VERSION IS OUT, and is now compatible with the latest (v0.95) version of fbcmd. You can find it HERE

EDIT 3: 02/DEC/08 - Fixed birthday issue for single digit days. Damn paddings...

EDIT 2: 23/NOV/08 - Fixed the incorrect date matching problem. You should update before the 2nd of December or you'll be in trouble.

EDIT: I fixed one serious error in the code, and updated the how to and made it..simpler.


let's face it, no matter how much you try you will always forget somebody's birthday and end up in a hole. I've been " " this close to death on several occasions now, and I'm actually reputed for having a good grip of the whole birthday business.

so last night I wanted to kill some time and I came up with a little bash script that might be of help to some of you. Basically what it does is

  1. Go online and grab the user ID's of everybody who's birthday falls on "today" (make sure your system clock is setup properly)
  2. Write a message on their wall

This is setup to run once a day, and voila! you have yourself a free ticket out of...birthday forgetters hell... *cough*

Should be fairly straightforward on any *nix system.

We'll be needing some way to access information on facebook. For that we're going to use fbcmd which is, as the developer describes "a simple command line interface for facebook." Go to the projects website here and download the latest version. At the time of writing, this was 0.90 (BETA)

Note that the patch file provided is for this particular version. I will update it if necessary in the future.

extract the archive to your home directory (places->home).
now download the patch file and script from here and also extract it to ~/fbcmd (directory should already exist from the previous archive)

Now go to the facebook application page, HERE and allow the application to access your information, and click "generate" to get an AUTH CODE for your account. Copy this down

open up a terminal now and run the following commands, one at a time.
sudo apt-get install curl php5-cli gnome-schedule
cd ~/fbcmd
patch -b -i fbcmd.diff fbcmd.php
php fbcmd.php AUTH XXXXXX
where XXXXXX is the AUTH CODE you copied down earlier. Now you should have access to your account through the application. Now we can move on to the wish script. In the same terminal type out the following.
php fbcmd.php FRIENDSC > fbUIDlist
gedit fbbdaywish
when the editor pops up, change the values for email, pass and put in your email ad and password. Change the value of "post" to whatever you want your friend to be greeted with. (TIP: avoid !'s, it causes some problems)

now type
gnome-schedule
The scheduled tasks dialog should come up. Click on new->recurrent. Enter any description you like. In the command field type
~/fbcmd/fbbdaywish >> ~/fbcmd/bday.log
uncheck the "no output" option, and select "every day" from the drop down menu. Click ok, and you're set to go!

Let me know how it turns out.

12 Comments:

Anonymous said...

this is like the third fucking time you changed it man. I was just coming in here to complain about you "Serious bug" (I think) but you beat me to it and fixed it.

thank you for the update, the new tutorial is much better. It took me an hour to decipher the last one

Anonymous said...

isn't there some way to pick a greeting at random from a list that I have stored some where?

SoE said...

That's easy! just insert the following line

post=`cat GREETFILE | while read i;do echo "${RANDOM} ${i}"; done | sort -n | sed -r "s/^[0-9]+ //" | head -n1`

right before the one that says wallpost ${i}

and change the value of GREETFILE to wherever you stored the greetings

echo7 said...

it worked! perfectly and on the dot of midnight! thank you dude you rock

Anonymous said...

Whoa my friend...Whoa!

Dave said...

Still some errors here. It fucks up every random day now and then

SoE said...

Yea I'm trying to sort those out as they arise. It's been pretty stable for me over the last...almost a month or so of testing. Only screwed up on me thrice, and I've been able to fixed the two bugs that caused the problem. The third is something I've yet to work on, but is somewhat minor at the moment.

Anonymous said...

Any hints on how to get Poking to work through command line?
I'm trying to adapt your script, but I'm not too familiar with curl.

Thanks

Andy said...

fbcmd.php has no "BDAY" command so your script doesn't work. I assume it did before.

SoE said...

no it still does. Are you sure you patched the fbcmd file with my diff file? because the BDAY function is something I wrote on my own and won't be there untill you patch it.


let me know if it still doesn't work. It has been working quite well for me here for three months now.

Thereme said...

Hello,

I tried to do it on windows where the Gnome command is not there, how do i do this on windows
machine?

Help much appreciated.

Vard

Anonymous said...

Hey,

Here is the example to automate birthday wishes on windows.

fbcmd WALLPOST =bday "!!! Many Many Happy Returns Of The Day !!!"

Vishal Palaskar

Post a Comment