Skip to content

Instantly share code, notes, and snippets.

@zlu
Created July 8, 2009 06:53
Show Gist options
  • Save zlu/142639 to your computer and use it in GitHub Desktop.
Save zlu/142639 to your computer and use it in GitHub Desktop.
#tropo example, playing twitter friends timeline
require 'json'
require 'net/http'
answer
say 'hello, welcome to your twitter status'
options = {
:choices => 'asha(1, asha), georges(2, georges), jason(3, jason), mark(4, mark), zhao(5, zhao)',
:repeat => 3,
:onBadChoice => lambda { say 'I am sorry, I did not understand what you said.' }
}
result = ask 'For asha, just say asha or press 1. For georges, say georges or press 2. For jason, say jason or press 3. For mark, say mark or press 4. For zhao, say zhao or press 5', options
screen_name = ""
if result.name == 'choice'
case result.value
when 'asha'
screen_name = 'asha'
when 'georges'
screen_name = 'georges_nahon'
when 'jason'
screen_name = 'jsgoecke'
when 'mark'
screen_name = 'map650'
when 'zhao'
screen_name = 'zlu'
end
end
statuses = JSON.parse(Net::HTTP.get(URI.parse('http://twitter.com/statuses/user_timeline.json?count=5&screen_name=' + screen_name)))
log statuses.inspect
say 'the last 5 twitter status for ' + screen_name + ' is'
statuses.each do |status|
log status.inspect
say status["text"]
sleep 1
end
hangup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment