Tuesday, January 13, 2009

ReeTweet : My First PHP/AIR/Twitter ...thing

Well, I am in 3-2 now (thats, IIIyr IIsem ) and its high time that I decided I go "deep", following one of the many paths open to me in the computer field. I can say I am marginally good in many things. Although its "many" its still marginally, I can make a simple webpage for myself, make a poster or two, edit some photos, write some codes, edit videos, mix audio, animate stuff in flash, do some DB management etc.. but nothing did I go too deep where I could actually say I am VERY good at.

My interesting in web-developing started back when I was a 12yr old making websites with flash navigation bars, but it stopped there, afterwards 10th class etc started and it was only curricular learning, extra-curricular things only involved "fun" :P

And seeing that I am very much interested in internet related developments, I thought that it would be better if I did something to expand my knowledge in this field.. So one fine day I asked @aalaap for some suggestions and after hearing what exactly I wanted to do, he suggested I learn PHP, and directed me to a nice learning place for beginners.

And I don't know why, just 5 Days ago it hit me that I should try out Adobe Air too (knew nothing about it till today) and just downloaded the SDK and stuff.

Lets fast forward to today, which after THIS happened, and also when I really started feeling that I should just have one small dabba with me using which I can just keep posting to twitter, not using a browser, so that I dont waste time stalking the timeline :P

So, I set my goal this morning (first "my" day of the holidays) to finally sit and see this Air thing and learn some PHP.

HelloWorld

So, I started off the day by reading how I could make my first "HelloWorld" app in Air. As I read on, I realized that the Air is really awesome! I dont know if there are already things like this, but its basically like having a browser window of your own! You just write HTML things like you would usually do for it to appear in a browser, and then you point that HTML file as the source for your app, and then Air creates a window showing that HTML page, making it look like its a standalone App.(FYI uses Webkit engine)

Pretty good it is! This technique of doing things compliments my forte very much!

So, I kept doing things from that HelloWord tutorial and within no time I had it successfully working.. no hitches or anything :D After doing that, I immediately shifted my attention to PHP

Monkeys are your best friend.

You have your code monkeys, greasemonkeys, lab monkeys, and lots more, @aalaap directed me to this "webmonkey.com" which has good resources and tuts for beginners and experts alike.

So I made my way to that place and then started reading the PHP for beginners tutorial. Everything is basically like just any other programming language you've learnt in the past, so learning that part was not that hard. The main thing was knowing exactly how things work, the way communication between HTML and PHP things happen and all that.

And once again, the way PHP and HTML work together seems like MAGIC, i.e compliments my interests :D

After reading the whole article, ( which I say should be THE way anyone should write tuts! ) I did a bit of experiments with Air and PHP.

Now comes Twitter!

So, after making myself comfortable with how all things work. I started looking at how the twitter API works.. its basically just updating a RSS feed. So I started looking up on how I access and update feeds using PHP, and webmonkey lead me to THIS place.

It has links to things that people have already done to use Twitter API, using different platforms. The main aim here is "Dont re-invent the wheel"

I.E. Rather than sitting and writing those codes of lines again just take them from others who are sharing it.. but this, if you're a beginner, stunts your knowledge..so what I did was just sit lookup all the methods and variables that the person used in his small code by going to PHP.net and tried to figure out what how it was working.

After spending a good amount of time I was comfortable with what all of it meant and what was exactly happening. I also realized that there is a looooooot more to learn.. its the just the beginning.

Here comes ReeTweet!

After observing everything, I finally started making the application. I just used the code provided there in the TwitterAPI Wiki, and then added forms in my HelloWorld HTML.

The first build I made had only Username and Password dabbas, along with the tweet area. Basically not much work was needed to be put into it. Just make your text areas, give them ids, POST the values to the PHP script and then update the twitter.com/statuses/update.xml using cURL commands.

So here is the Box you've all been waiting for!

So simple, is it not?

So, after a few hours of reading and trying out various things, I was finally able to get the thing done in the same day!

First I thought only email id can be sent for the authentication so tweeted that.. then I tried using my Userid instead. It works both ways! :D



It echo()s these lines of text after submitting, I guess I can use the information and then render a nice page after submit :D

Afterwards, I realized that there was no point in using the userid and password, as this was something I created for myself.. so made the simple dabba I was talking about :D



So, yeah thats how I am leaving it for today.. will see more next time.

My app Link is where?

One of the main things that I wanted was that I will get "from ReeTweet" whenever I make the post.. I used to think that it was a parameter in the XML file that I should be updating in order to give the name and link.. but after looking around a bit.. it turns out that .. inorder to get "from app" and make it link to someplace, you must "File a request" and it has many constraints set.

It was very discouraging :( I dont see why they should do that, I mean, make it possible via some xml parameters and people who make things can show it.. I dont see how it can be "abused" linking to something there is similar to linking something in your tweet. Well, I guess its them being on the safe side, or maybe doing that to have an "exhaustive" list of all the apps that people are making.

I just hope that after I finish working on the thing I can get permission to mention my app :P

So what's next?

Well there's LOT of stuff to be done! I didnt take any security measures, and neither did I make more "personalized" here is a small list of things I want to do.

  • Look around about what security measure should be taken
  • Go back to main page after successfully posting!! (right now have to restart the app :P )
  • Add script to show remaining characters.
  • AJAXify IT!!
  • Make my own icon
  • Make a nice BG
  • Show @replies in another tab
  • Count number of tweets in current session and show
Well thats only a start, I just hope I learn a lot of things doing that :D

Final Thoughts

There is no guarantee that I will be doing web development in my future, as in, job.. but for the moment, I am loving and will keep doing it till..well.. circumstances force me to do something else... I wouldn't be sad if it had something to game programming :P (comfortable with designing algorithms there too :D )

And as for AIR, I have to say! Its far far FAR better than me having to make those swings/jFrames applets in java, this feels so natural to me, and very comfortable with it! Swings and all feel so scary when you look at them, and doing this in Air is... just so ME.

So.. yeah, thats it about what I did today, Now I will look into where I should go next to learn more about PHP, the exhaustive lists and everything at PHP.net are a bit scary :S

4 comments:

Mako said...

Great wotk buddy. Even i have been wanting to develop an AIR application for so long. Maybe this post is going to be my inspiration.

Reeteshifier said...

Thanks! Hope you do it soon, as you can see its really easy and fun :D

Do share you experiences too!

Quiz_Master said...

OH! Man Oh!

I've developed similar apps to retrive RSS feeds and stuff like that, but this one is awesome.
Keep up the good work, and when its complete enough- Release it as Open Source =D

Reeteshifier said...

Thanks a lot man :D

Will be improving upon it soon! And yeah, I think when it'll be done, I will do 'ol man RMS a favour and make is Free Software (not open source).

Afterall, he and his foundation made my college life more exiting than it would have been!