Today's Smalltalk Daily looks at using xAuth to connect to a public web service - in this case, Twitter. The code I used in the screencast is below - to load that code, get the packages OAuth and MinXAuthTwit from the public store repository. To skip to the video, click here..
"the entire conversation with Twitter" auth := XAuthenticator fromSettings: (OAuth.Settings fromFile: 'twitterOAuth.ini'). accessData := auth executeXAuthAccessTokenRequest. postCollection := OrderedCollection new. postCollection add: 'status' -> 'Testing xAuth to Twitter from Smalltalk'. auth executeXAuthCallFor: postCollection with: accessData to: 'http://api.twitter.com/1/statuses/update.json' "save the results as a file for addition to any RSS/Atom aware tool" file := 'calFeed.xml' asFilename writeStream. file nextPutAll: xml. file close. "Using the simpler package I published" MiniTwitPoster tweet: 'Test Tweet from simple interface object'
If you can't see the embedded video directly, you can go directly to YouTube for it. To watch now, click on the viewer below:
You can follow the Smalltalk channel on YouTube for all the "Smalltalk Daily" videos. You can also check out the videos on Vimeo, where the quality is higher, or over on Facebook, if you are a member.