260 likes | 575 Views
VOICEMAIL. ROB – GONZEE.TV. HI. I’M ROB ! (yet again). FIRST APP ON BOXEE. LAUGH-O-TRON. SCOPE THIS MY NINJA. (totally demoing Laugh-o- Tron ). WHERE O’ WHERE. TELEVISION. BOXEE FTW!. (totally demoing voicemail app). LAUGHOTRON VOICEMAIL. Resources Intro to Boxee GUI
E N D
VOICEMAIL ROB – GONZEE.TV
SCOPE THIS MY NINJA (totally demoing Laugh-o-Tron)
BOXEE FTW! (totally demoing voicemail app)
LAUGHOTRON VOICEMAIL • Resources • Intro to Boxee GUI • Intro to Twilio REST API • CODE oh snap!
GET MACGUYVER ON IT • List Containerhttp://developer.boxee.tv/List_Container • Twilio Python modulehttp://www.twilio.com/docs/libraries/ • ElementTree (or your XML parser of choice)http://effbot.org/zone/element-index.htm
HOW IT WORKS REST XML
BOXEE GUI • XML Driven • Controls • Python Events <?xml version="1.0"?> <window type="window" id="14000"> <defaultcontrol always="true">111</defaultcontrol> <allowoverlay>yes</allowoverlay> <controls> <control type="group"> </control> </controls> </window>
LIST CONTAINER <control type="list" id="111“> <onright>-</onright> <posx>160</posx> <posy>60</posy> <width>960</width> <height>570</height> <orientation>vertical</orientation> <itemlayout> </itemlayout> <focusedlayout width="960" height="80"> </focusedlayout> <content type="action"> </content> </control>
ONLOAD EVENT <?xml version="1.0"?> <window type="window" id="14000"> <onloadlang="python"><![CDATA[ #TOTALLY PUT YOUR CODE HERE ]]></onload> <defaultcontrol always="true">111</defaultcontrol> <allowoverlay>yes</allowoverlay> <controls> <control type="group"> </control> </controls> </window>
CODE! import twilio import elementtree.ElementTree as ET # Twilio REST API version API_VERSION = '2008-08-01' # TwilioAccountSid and AuthToken ACCOUNT_SID = ‘INSERTACCOUNTSID' ACCOUNT_TOKEN = ‘INSERTSECRETTOKEN' # Create a Twilio REST account object using your Twilio account ID and token account = twilio.Account(ACCOUNT_SID, ACCOUNT_TOKEN)
MORE CODE! # Use the Recording resource to get all the recordings from our account try: response = account.request('/%s/Accounts/%s/Recordings' % (API_VERSION, ACCOUNT_SID), 'GET') except Exception, e: print e print e.read() # Parse result response = ET.fromstring(response)
WAIT – THAT’S NOT MUCH CODE? container = mc.ListItems() for recording in response.findall("*/Recording"): newitem = mc.ListItem(mc.ListItem.MEDIA_AUDIO_SPEECH) newitem.SetLabel(recording.findtext('DateCreated')) newitem.SetDuration( int(recording.findtext('Duration')) ) newitem.SetThumbnail("http://apps.gonzee.tv/laughotronvoicemail/images/thumb.png") newitem.SetProperty("Sid", recording.findtext('Sid')) newitem.SetProperty("AccountSid", recording.findtext('AccountSid')) newitem.SetProperty("CallSid", recording.findtext('CallSid')) newitem.SetProperty("DateUpdated", recording.findtext('DateUpdated')) newitem.SetPath('https://api.twilio.com/%s/Accounts/%s/Recordings/' % (API_VERSION, ACCOUNT_SID) + recording.findtext('Sid') + ".mp3") container.append(newitem) list = mc.GetWindow(14000).GetList(111).SetItems(container)
10001110111 • Downloadhttp://dir.gonzee.tv/download/tv.gonzee.laughotronvoicemail.zip • Checkoutsvn checkout http://twilio-boxee-hackathon.googlecode.com/svn/trunk/voicemail/twilio-boxee-hackathon-read-only