The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Using Twitter from the Blog Server

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Using Twitter from the Blog Server Posted: Dec 9, 2008 3:16 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Using Twitter from the Blog Server
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

As Ramon Leon says, one of the neat things about having your own blog server is that you can always write about little tweaks you make, and there are always more tweaks possible. So - I've had the server sending updated to Twitter every time I post for awhile now. The implementation was pretty lame though - I dropped two methods directly into my BlogEntry class and had it do the update. I finally decided that this was a smelly, and built a small package (MiniTwit in the public store.) There are two classes - a Settings class, to make it possible to set up a simple ini file, and the class that does the work. The code is dead simple:


"now send update"
ifc := TwitterInterface
		username: username
		password: password.
ifc possiblySendTwitterUpdateFor: 'Sent from VisualWorks 7.6 - Testing'.

The code for the method that does the work is pretty simple as well:


possiblySendTwitterUpdateFor: string
	|  update client |
	self canSendTwitterUpdate ifFalse: [^self].
	update := Net.URI encode: string.
	client := HttpClient new.
	client 
		username: self settings twitterUsername 
		password: self settings twitterPassword.
	[[client 
		post: (self settings twitterBaseUrl, update)
		contents: '']
	on: self httpExceptions
	do: [:ex | nil]] fork

Pretty simple stuff, and in the case of an HTTP error, it just silently fails with a nil (not sending to Twitter is hardly the stuff of tragedy :) )

So now in my BlogEntry class, I just use that, and I have the Twitter code nicely isolated.

Now Listening to: Winterblue (Album Version) by Heather Nova from: Siren

Technorati Tags:

Read: Using Twitter from the Blog Server

Topic: Topic for January Previous Topic   Next Topic Topic: Even More on Implicit Receivers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use