Post on 28-Mar-2015
transcript
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
ResourcesIntro to Boxee GUIIntro to Twilio REST APICODE
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
THE CAKE IS A LIE
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">
<onload lang="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 twilioimport elementtree.ElementTree as ET
# Twilio REST API versionAPI_VERSION = '2008-08-01'
# Twilio AccountSid and AuthTokenACCOUNT_SID = ‘INSERTACCOUNTSID'ACCOUNT_TOKEN = ‘INSERTSECRETTOKEN'
# Create a Twilio REST account object using your Twilio account ID and tokenaccount = twilio.Account(ACCOUNT_SID, ACCOUNT_TOKEN)
MORE CODE!
# Use the Recording resource to get all the recordings from our accounttry: response = account.request('/%s/Accounts/%s/Recordings' % (API_VERSION, ACCOUNT_SID), 'GET')except Exception, e: print e print e.read()
# Parse resultresponse = 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)
DONE
QUESTIONS?
10001110111
Downloadhttp://dir.gonzee.tv/download/tv.gonzee.laughotronvoicemail.zip
Checkout svn checkout http://twilio-boxee-hackathon.googlecode.com/svn/trunk/voicemail/ twilio-boxee-hackathon-read-only
KTHX