Its a busy life we live, isn’t it?
The day starts and ends and we have no clue what did we do the whole day. No time to catch up with friends, no time to stay home and spend some quality hours with ourselves.
And in all this hustle and bustle, we often miss on events, even miss wishing our friends their birthday, in spite of getting daily updates on Facebook. Also, we may forget wishing them if we don’t visit our Facebook account on daily basis. I wanted a solution to this. So I started making a Facebook app which fetches birthdays from your friends’s account and wishes them on their birthday automatically.
The app will automatically post “Happy Birthday <friend’s-first-name>! :)” to your friend’s wall from your FB account.
I started tinkering with Facebook API and found that most of the things were in PHP. I wanted a Python API for Facebook and found pyfacebook – A Python Interface to Facebook.
I started making an app on developers.facebook.com
Things mentioned are quite clear. You can easily make your app reading those guidelines. And then use Heroku or maybe Google App Engine to write the code.
I used Heroku and found it pretty easy to understand. The web interface is pretty impressing. Neat.
So I started with my code. Used OAuth since app required ‘friends_birthday’ and ‘offline_access’ permissions from user to authenticate the app to begin with. If this was done, the platform was set. Then there was just the need to write a few tens of lines of code to get through with the app.
The problem I faced was, ‘offline_access’ falls under Extended Permissions category and ‘friends_birthday’ is under User and Friends Permissions category. I tried to get ‘offline_access’. It worked pretty well. The problem was with getting ‘friends_birthday’ from User and Friends Permission. There were a few things I tried doing.
I tried to get the permissions by passing two calls (Only a part of the code is shown here)
facebook.auth.createToken() #Show login window facebook.login() #Log in to the window and then press enter print "After you log in, press enter" raw_input() facebook.request_extended_permission('offline_access') raw_input() facebook.request_basic_permission('friends_birthday') raw_input()
But this did not work.
I posted on stackoverflow about this. Immediately I got a response suggesting me to ask for all the permissions in the single call. It seemed right because I came across fb:prompt-permission page where they have clearly passed various permissions like email, publish_stream, offline_access, create_event in the same category, separated by commas.
So I tried doing that as well. A part of the code was modified to
facebook.auth.createToken() #Show login window facebook.login() #Log in to the window and then press enter print "After you log in, press enter" raw_input() facebook.request_extended_permission('offline_access', 'friends_birthday') raw_input()
But, even then it did not work. Ultimately I got to know that Facebook has always been in process of making changes with the API and the pyfacebook that I was using was really a very old python facebook interface. *sigh*
There are many things Facebook is changing and I don’t know and don’t understand why.
One important thing I would like to mention is the change in the Authenticaion policy that Facebook has implemented lately is
I tried to find for some other Facebook API which used Python. Did find a few complicated things for which I had to go through some really complex Django part. Doing that for just getting through a simple and small thing did not make me any happier.
So, for now this code has been pushed to my GitHub account. Have a look and I would be glad if you can help.
Now, I am onto another project which deals with Twitter lists and Trello. As I am done with it, will blog about it.
Till then, adios!
Keep coming back!