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'
To watch now, use the viewer below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Technorati Tags:
smalltalk, twitter, xAuth, http