Virendra Rajput (BkVirendra)

home me my projects

How I keep my Facebook Page active using Cron Jobs!

By Virendra Rajput Tagged:

I have this habit of forgetting important tasks, lately. Since multitasking is never an easy job, to do and you tend to forget alot. Being a regular member of the Brahma Kumaris community, I was looking forward to contribute to the community some way possible.

Hence, I was thinking of creating an Online presence of the community. So after a while, I created a Facebook Page for Brahma Kumaris, where I used to share Daily Muralis along with videos for classes, that I had to fetch from various sources online. 

The Murali was available in plain text and the videos were being posted at Brahma Kumaris Youtube Channel. The Murali was available in 2 languages viz. English and Hindi at Brahma Kumaris Jewels.

I did the task of updating the Page manually for a while, but it wasn’t possible for a lazy guy like me to do it long, considering all the lazy habits I have. And it was important to update the Page exactly in the morning, so that it would reach members all around the globe.

I added a few fellow members of the community as the Admin of the Page, so that they could help me with updating the page, regularly. But still we weren’t able to keep it updated.

So I decided to solve the problem, the HACKER WaY. And finally came up with the script that I developed in 2 hours approximately, when I challenged my Bro, that I would get it done in an hour, but it took me an hour more.

After testing it, thoroughly, and adding support for Hindi language, I created a Cron Job, that would run exactly at 9:30 AM, everyday.

The script would fetch the Jewels Brahma Kumaris Page, and would parse it to get the Murali text from it, and then filter it to remove any special characters, or so.

Then it would make a post request to the Facebook Graph API with all the required credentials, and get the Murali posted on the Page. Since the murali was available in 2 languages, I had 2 different scripts, for handling each language.

Then I had a script for fetching the Class video from the Brahma Kumaris Youtube Channel. This script would get today’s Murali class video, and would post it on the page.

The scripts have really been useful, for keeping the Page updated regularly, and have contributed  in increasing the Page Reach and Likes as well. Currently, the Page has 5,990 likes. And around 350+ people talking about this. Now, I rarely have to check the page, since the Cron manages it all.

Well, I mostly prefer Python, but I used PHP to create these scripts since, Python has a lot of hosting issues. I was considering hosting it on Heroku, but again Heroku doesn’t provide Cron for free. Hence PHP was a better option, again.

You can fork the script on Github here.

I would like to hear from you, about any such similar situations that you have come across, and how you managed to solve it!