I do enough things with Smalltalk and social media sites like Twitter that I thought having a little service interface to TinyUrl would be useful. So, I created one. Very simple usage model:
TinyUrl.Shortener shorten: 'someLongUrlStringHere'
The code is in the public repository, in package TinyUrlInterface. The guts of it are short enough that the package almost isn't worth it, but I use this kind of thing a fair amount:
client := HttpClient new.
response := client
post: 'http://tinyurl.com/create.php'
formData: (Array with: 'url' -> 'http://www.longUrlHere.com').
stream := response contents asString readStream.
stream upToAll: '<blockquote><b>http://tinyurl'.
stream throughAll: 'b>'.
tinyUrl := stream upTo: $<.
Pretty basic stuff, but I thought it might be useful for anyone doing Http interface work in Cincom Smalltalk :)
Technorati Tags:
tinyurl, url shortener