Yes, It does what it tells it does. It may be one of the geekiest ways of wishing your friends on their birthdays. You won’t have to check every morning for people having birthdays, and go on writing on their walls. The script does it for you. And believe me, when you wish someone using a script for the first time, it feels terrible. You will start to see the fickleness, frailness of human relationships, freaks and fakes around us in a Web 2.0 world. But, if you dare to go forward and test it for yourself, scroll down to see the step-by-step instructions.

Step 1: Install cURL and Gnome-schedule

cURL is a command line tool for transferring data using various protocols. Gnome-schedule is a GUI for managing cron-jobs. Install them by running the famous command

sudo apt-get install curl gnome-schedule

Step 2: Setup a new application

Goto http://www.facebook.com/developers/ and setup a new application. Fill in all the required fields. Don’t forget to set ‘Application Type’ to ‘Desktop’. Remember the ‘Application ID’ and ‘Application secret’ given in the end of the process.

Step 3: Request an OAuth access token with the proper permissions

Facebook Graph API authorization documentation Has a detailed explanation about this. But if you are in a hurry,

Enter the following URL in your browser, replacing YOUR_APPLICATION_ID with the application ID you got in the earlier step. https://graph.facebook.com/oauth/authorize?client_id=YOUR_APLICATION_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&scope=offline_access,publish_stream,friends_birthday After a successful login and granting necessary permissions, you will be given a verification code. Save it for later use. Enter the following URL in your browser, replacing YOUR_APPLICATION_ID with ‘Application ID’ and YOUR_API_SECRET with ‘Application secret’ you got earlier, and VERIFICATION_CODE with the code you got in the previous step. https://graph.facebook.com/oauth/access_token?client_id=YOUR_APLICATION_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=YOUR_API_SECRET&code=VERIFICATION_CODE Now you will be given the precious ‘Access Token’. Save it somewhere

WARNING: Facebook does not recommend following this procedure and storing Access Tokens or Application secrets in desktop applications, because if somebody gets hold of that code, you are dead. I mean your facebook profile security is severely compromised and can be used in any malicious way they desire.

Step 4: Writing the script

No. Actually you just have to copy the following script I wrote and save it in a file like ‘/home/yourName/birthdayscript.sh’ after entering THE precious access token of yours in the proper place.

#!/bin/bash NOW=$(date +"%m/%d") #Enter your access token below within quotations ACCESS_TOKEN="blah-blah-blah-your-precious-access-token" #Get the names and UIDs of your unfortunate friends born on a day like today curl "https://api.facebook.com/method/fql.query?access_token=$ACCESS_TOKEN&query=SELECT%20first_name,uid%20from%20user%20where%20uid%20in%20(SELECT%20uid2%20from%20friend%20where%20uid1=564121985)AND%20substr(birthday_date,0,5)%20==%20'$NOW'" > birthdaywishtemp.xml names=`sed -n -e 's/.*<first_name>\(.*\)<\/first_name>.*/\1/p' birthdaywishtemp.xml` ids=`sed -n -e 's/.*<uid>\(.*\)<\/uid>.*/\1/p' birthdaywishtemp.xml` F_ARRAY=( `echo ${names}` ) U_ARRAY=( `echo ${ids}` ) #Wish each of them with the same old boring message for (( i = 0 ; i < ${#U_ARRAY[@]} ; i++ )) do curl 'https://graph.facebook.com/${U_ARRAY[$i]}' curl -F 'access_token='$ACCESS_TOKEN'' \ -F 'message=Hey, Happy Birthday...'${F_ARRAY[$i]} \ https://graph.facebook.com/${U_ARRAY[$i]}/feed >> birthdaywishbackup.log #Let you know the progress echo "Wished ${F_ARRAY[$i]}" >> birthdaywishbackup.log done echo "Completed on $(date)" >> birthdaywishbackup.log

Now you can browse to the location where you saved the script via terminal and execute the script with the command

./birthdayscript.sh

And you can see the progress in the file birthdaywishbackup.log

Step 5: Automating the script

Yes, it is of no use if you have to run this manually each and everyday to wish somebody. So you can schedule it to run and write automagically on walls of birthday boys/gals everyday. If you are the geekiest type you can do it using a cron-job and you won’t need this tutorial anyway. But if you are interested, you can find how to do that here.

For the ordinary geek, there’s this dumb-simple GUI based tool called gnome-schedule. Run the command

gnome-schedule

in a terminal and you will be able to come up with a scheduled cron-job like the following in few easy steps.

IMPORTANT: Make sure you set a time of the day that you will keep your computer switched on, because a cron-job is not god, and doesn’t know how turn on the computer it is running, by itself 😀

It’s done!!! Enjoy being a lazy, cold-hearted nerd, who has no sense of finer things in life.

UPDATE: With all the controversial comments about this post here and in Reddit, I found an article written by another one who has thought on the same lines which totally explains my idea behind this script and blog post. Read and post your comments