Tuesday, 21 April 2009

Finally twittering

Yes I've finally given in and got a twitter account, mainly because I'm bored and spotted the Twitter API Wiki.

It works with technologies at the top end of web fun such as JSon, XML and REST.
It gives simple examples for using cURL with the JSon and XML elements. Like below
this cURL line updates the status on twitter (command line updates anyone? :P)



degus:/var/www/# curl -u netphunk:******** -d status="Status update from cURL" http://twitter.com/statuses/update.json
*snip JSon output because its boring :)*
degus:/var/www/#


And sure enough the -d status="" text appeared as my "What are you doing?" status on twitter woop.
Now thats all good but mastering the API in one line isnt enough for me so I made a version of the same principal but using the wget tool instead, just so I could look kool :D


degus:/var/www/# wget --post-data="status=Stats update from wget" --http-user=netphunk --http-password=*** http://twitter.com/statuses/update.json
--2009-04-21 20:42:23-- http://twitter.com/statuses/update.json
Resolving twitter.com... 128.121.146.228
Connecting to twitter.com|128.121.146.228|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to twitter.com|128.121.146.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 948 [application/json]
Saving to: `update.json'

100%[======================================>] 948 --.-K/s in 0s

2009-04-21 20:42:25 (159 MB/s) - `update.json' saved [948/948]

degus:/var/www/#


Yay it works all good :D Twitter is still a mystery and the way it autoatically connects people has some privacy debate questions behind it but it's got a very innovative API that looks good fun, nothing like updating blog style from a quick command line hack right?

No comments:

Post a Comment