By
Norty | April 5, 2010 12:39
Generating automatic content for your Facebook friends and Twitter followers can make life a little easier for you. Let’s face it; there just is never enough time in the day to keep up with everything we would like to. It seems like the “to do” list keeps growing, but the hours in the day remains the same. While it is important to keep the content on your Facebook and Twitter pages fresh and up to date sometimes you blink and it’s 11:00 at night, you still have last months Facebook status and can’t even remember the last twitter update you made. My solution was to create a script that will update Facebook and Twitter automatically for me every day. This way the content is both fresh and more available to searches. I decided to share the process with others and maybe it could save you a few minutes a day.
Ingredients Needed
- Facebook Page / Twitter Account
- Selective Tweets on Application on Facebook
- A Mysql Database
- Perl (this is the language I used, but it can be done with another language)
- Cron or other scheduling software.
The first thing you will need to do is install the Selective Tweet application in Facebook. Selective Tweet will watch a Twitter feed for the phrase “#fb” and if a Tweet contains that phrase it will also update your Fan Page status with that Tweet. On the “Your Fan Pages” tab of Selective Tweet you can enter the Twitter account you would like your page to monitor.
Next we will need to set up the database. I am using a MySQL database because they are lightweight and easy to use. Inside my database I created a simple table with only 3 columns. An unique ID field, a Year Day Field and a Message field. Then I populated the table with one message for everyday of the year, 366 in total to take into account leap year. And in the ID and YearDay columns I entered 1-366. So for the record with YearDay of 94 I would have entered “Happy Easter” as the message because the 94th day of this year was 04/04/2010 (Easter).
Once you have the database setup you can then work on creating the script to update the Twitter account. You can use Perl to post a status update to a URL. What I do is select from the table where the YearDay is (localtime)[7]+1 (which will return the system YearDay). I then use the below command to send the message for the current YearDay to Twitter and append #fb so that my Facebook page will also be updated.
system "curl --basic --user $username:$password --data-ascii status='" . $tweet->{Message} . "#fb' http://twitter.com/statuses/update.json";
Since I have my application on a Linux machine I am using cron to schedule the script to run once a day at 7:00am. If you are on a windows server you can also use Scheduled Tasks to fire off the script.
And that is all there is to it. Now I will have fresh content on my Twitter and Facebook accounts that will hopefully drive more traffic to them. It also allows me the chance to get some of the other things on my to do list done, like mow the grass.