Created
August 9, 2012 08:19
-
-
Save iorionda/3302294 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# vim:fileencoding=utf-8 | |
from optparse import OptionParser | |
import httplib | |
import urllib | |
import settings | |
usage = "usage: %prog [Option] tel_to_number" | |
parser = OptionParser(usage=usage) | |
(options, args) = parser.parse_args() | |
tel_to = args[0] | |
def main(): | |
# user serial | |
serial = settings.Serial | |
# API access key | |
key = settings.Key | |
# voice file | |
filename = settings.Filename | |
url = 'boundio.jp' | |
headers = { | |
"Content-type": "application/x-www-form-urlencoded", | |
"Accept": "text/plain"} | |
path = '%s/%s/%s' % ('/api/vd1', serial, 'call') | |
cast = 'file(%s)' % filename | |
params = urllib.urlencode({'key': key, 'tel_to': tel_to, 'cast': cast}) | |
try: | |
conn = httplib.HTTPSConnection(url) | |
conn.request("POST", path, params, headers) | |
response = conn.getresponse() | |
data = response.read() | |
except: | |
print(data) | |
finally: | |
conn.close | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment