Skip to content

Instantly share code, notes, and snippets.

@ObjectIsAdvantag
Last active April 17, 2016 12:21
Show Gist options
  • Save ObjectIsAdvantag/6320e2690b48dc9b0b53d60eb4039528 to your computer and use it in GitHub Desktop.
Save ObjectIsAdvantag/6320e2690b48dc9b0b53d60eb4039528 to your computer and use it in GitHub Desktop.
Tropo Outgoing POST - application/x-www-form-urlencoded
import urllib
import urllib2
version = "v20160417 - 0702"
log( version )
answer()
say( "Welcome to the python v" + version )
log( "outgoing call: before" )
# GET sample
#response = urllib2.urlopen( "http://requestb.in/zd4mlazd" + "?input=hello" )
# POST sample
# This urlencodes your data (that's why we need to import urllib at the top)
data = urllib.urlencode( { "input":"hello", "from":"[email protected]" } )
response = urllib2.urlopen( "http://requestb.in/zd4mlazd", data )
log( "outgoing call: after" )
if response :
log( "outgoing call: worked" )
say( "your answer has been posted" )
else :
log( "outgoing call: error" )
say( "I am sorry, Error occured while sending your answer" )
say( "Thats all. Goodbye!" )
hangup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment