Peter's Blog

Redefining the Impossible

Items filed under twitter


I think I had an original Twitter idea, albeit a bit of a detail. When I post an article to my blog, my auto-tweeting announcement thing will now include hashtags generated from the blog tags.

Not seen this done before.

I looked into using oauth for Twitter authentication as the basic authentication waves your password around in a terribly blatant way. Couldn't get it running from a command line ruby script such as a rake task launched from procmail (like I am posting this). It was almost like it's locked into usage in a web app. A plan to thwart spambots or just my ineptitude? Don't mind the former, latter is always embarrasing.


1 Comment

Woo hoo, O2 uk have set up free Twitter text notifications:

Free Twitter Texts

Can receive 600 a month before being banned for abuse! Have to pay to send but:

  • haven't posted a tweet manually for weeks
  • if I did I'd use Tweetie 'cos it's free

Filed under: twitter


My main twitter client is Tweetie and I don't scan it all the time so I often miss replies that are sent to me, sometimes for a few days (I don't check the 'mentions' page). Despite this sentiment I don't want to miss any replies as they can be quite important (e.g. direct questions).

I do check my email regularly so I thought it would be nice to be emailed if I had new replies. Surprisingly, twitter.com only does this for direct messages so I wrote something to do the job for me:

This runs from a cron job every half hour so hopefully I won't be accused of API abuse.

BTW this is the first time I have embedded a github gist in the blog so I don't know how nicely it will work.


Filed under: github ruby twitter


If all goes to plan petersblogger should automatically post a tweet on Twitter telling the world about this blog post. The life story of this tweet is:

  • I type this post into the iPhone wordpress client app
  • the post is posted to a wordpress blog
  • petersblogger reads the rss feed from wordpress and imports the new post
  • it uses the Twitter gem to post the tweet

Simple.

I'd love to post some source but the iPhone doesn't have cut and paste…


Filed under: peterblogger twitter


10 lines of ruby, one blank. Sorry no comments.

Twitter Client

Twitter Client

Gotta love ruby gems.


Filed under: rails twitter


This is how I gather my twitterings into the blog. I just scrape the rss feed. The twitter api may allow for something more sophisticated but this Just Works.

It's just too easy in ruby/rails:

   1  class TwitterHandler
   2    def update( strFile)
   3      require 'open-uri'
   4      require 'simple-rss'
   5  
   6      oRss = SimpleRSS.parse( open( strFile))
   7  
   8      oRss.items.each do |oItem|
   9        strBody = oItem.description
  10        strBody.gsub!( /^petersblog: /, '')
  11        strTitle = "Twittering: #{oItem.pubDate.strftime( "%d %B %Y %H:%M")}"
  12  
  13        if not Post.find_by_title( strTitle)
  14          oPost = Post.new( :title => strTitle, :body => strBody, :created => oItem.pubDate)
  15          oPost.Taglist = "twittering"
  16        end
  17      end
  18    end
  19  end
  20  
  21  The above is only wrapped in a class because that is how the first rspec example I read was laid out.
  22  
  23  Then there is a rake task to run the above:
  24  
  25  <ruby>
  26  task (:twitter => :environment) do
  27    require 'lib/TwitterHandler'
  28  
  29    oTwitter = TwitterHandler.new
  30    oTwitter.update( "http://twitter.com/statuses/user_timeline/16738335.rss")
  31  end
Toggle Line Numbers

Then a cron job:

13,28,43,58 * * * *  bash -c "cd /var/www/PetersBlogger/current; rake -s RAILS_ENV=production twitter"

This polls every 15 minutes. The '-s' stops rake outputting a needless 'In directory blah' message which cron dutifully emails to me.

I'm enjoying using twitter, I like the medium, short and pithy. Not really suitable for code snippets though.



I've added a twitter feed to the blog. I'm looking to see if I can use it as a kind of real time brain dump for junk that's not worth a full blog post. I won't be posting what I am doing all the time because that's just asking for trouble.

The twitter link is http://twitter.com/petersblog (but you probably guessed that).