Categories
PHP

Twitter OAuth Fun :D

My University is off for about a month and I am thinking of passing this huge time in some sort of productive work. I love coding and experimenting. Twitter and PHP being my favourites, I decided to check out the Twitter API and cook something up with PHP. I have already used the Basic Authentication API calls in the past (to develop the twitter mobile publisher at https://masnun.com/twitter/ which is my major tool to tweet while I am on the go). This time I decided to try the OAuth API mainly for two reasons — 1) I need to explore the OAuth system and 2) I have a project coming on based on the twitter OAuth API.

So, I started studying the Twitter OAuth API and learnt it pretty well. Then I thought what kind of application I could build with this very newly gathered knowledge ? Why not make some fun ? Yeah, I just can’t help making fun every now and then.

Finally, here it is — https://masnun.com/twitter-app/ 🙂

It’s a little devil app that automatically takes you to the authorization URL and asks for OAuth based authentication. If you allow it, it will automatically make a tweet using your account. The tweet will be nothing bad though, just a link back to the app 😉

To develop this app, I have used the official Twitter OAuth library for PHP written by Abraham. Download it: http://github.com/abraham/twitteroauth .

Points to Ponder:

  • An application can do almost anything to your twitter account once you approve it.
  • Twitter says, the access token they provide doesn’t expire. That means once you approve an application, it can use your account forever if they are clever enough to store your access token details.
  • While approving an application, you never know what kind of permission the application has — read only or read-write both. I think this option should be left upon the users. The users should be able to choose whether he wants to provide write access or not.

I have seen some web sites exploit Twitter accounts. TweeterFollow is a decent example of such nasty practices. Once you provide your credentials, they’ll regularly tweet their links from your account. So think twice before you approve an application though OAuth is safer than providing password since you can choose to withdraw your permission to an application.

I will write detailed about OAuth and provide the source code in another post. Just now, I am feeling extremely sleepy. Woke up to have my Sehri and didn’t return to bed. It’s time I had a nap… 😉

Categories
PHP

Converting Videos Using PHP

In fact, video conversion on the server side is done by other softwares. PHP itself is used as a medium for the task maximum times.

We have a nice command line tool named “ffmpeg” to convert videos. I am currently working on a youtube video conversion tool and using ffmpeg to convert the videos from “.flv” to my desired format.

On my linux machine this simple command is enough to convert a “.flv” video to “.mpg” :

Using php, I do the same. PHP has a function shell_exec() that lets you execute any shell command from PHP. So, this is what I do from PHP:

That does the job for me 🙂

Categories
Personal Work

Twitter Bot Earns Me Money :)

Well, this came up as a pleasant surprise to me when I logged into my GetAFreeLancer.com account to deactivate the email notification. I have earned $34.2 in August 2009 from affiliate activity. I was puzzled first and then checked out the whole thing. One of the people whom I referred to GAF, created two projects there and I got the commission.

I am quite active on scriptlance and was getting bored with GAF for their very frequent email notification. Finally, I decided to turn off the notifications and deactivate my account. But now that GAF is earning me money from referrals, I am quite happy with them.

The referral links are being spread over the microblogsphere by my twitter bot that collects direct links to available projects on GAF and tweets them. I set up the bot out of experimental purpose but now it looks like it’s gonna be a good money maker as well.

Being inspired by this little surprise , I made some upgrades to the bot. The bot now adds hash sign (#) before important key words to make it search friendly. I also activated a identi.ca and a friendfeed clone of the same bot.

I am thinking of selling this entire bot script at $30. Anyone interested? Bargaining allowed for sure ;-).