Skip to content

iqbalabd/xoxzo.cloudpy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xoxzo Cloud API Client for Python

This is the official client and implementation reference to talk to Xoxzo's Cloud Communication API. For detailed documentation on the API itself, you can refer to the documentation

Introduction

xoxzo.cloudpy is the paython package that you can send sms or make a phone call and playback a MP3 file via Xoxzo telephony API. This is the open source package with MIT LICENSE.

Sample Code 1

Send sms:

def sample_send_sms():
   xc = XoxzoClient(sid="<your xoxzo sid>", auth_token="<your xoxzo auth_token>")
   result = xc.send_sms(
       message = "Hello from Xoxzo",
       recipient = "+818012345678",
       sender = "818011112222")
   if result.errors != None:
       # some error happed
       print json.dumps(result.message, indent=4)
   else:
       # check messge delivery status
       msgid = result.messages[0]['msgid']
       result = xc.get_sms_delivery_status(msgid)
       print json.dumps(result.message, indent=4)

Explanation

You can send sms or make a phone call with just a few line of python code.

  1. First, you need to create XoxzoClient() object. You must provide xoxzo sid and auth_token when initializing this object. You can get sid and auth_token after you sign up the xoxzo account and access the xoxzo dashboard.
  2. Then you can call send_sms() method. You need to provide three parameters.
  • message: sms text you want to send.
  • recipient: phone number of the sms recipient. This must start with Japanese country code "+81" and follow the E.164 format.
  • sender: this number will be displayed on the recipient device.

This method will return XoxzoResponse object. If XoxzoResponse.errors == None, XoxzoResponse.messages[0]['msgid'] is the meesage id that you can pass to the get_sms_delivery_status() call.

  1. You can check the sms delivery status by get_sms_delivery_status() method. You will provide message-id of the sms you want to check.

Sample Code 2

Make a phone call and playback MP3 file:

def sample_call_simple_playback():

   xc = XoxzoClient(sid="<your xoxzo sid>", auth_token="<your xoxzo auth_token>")
   result = xc.call_simple_playback(
       recipient="+818012345678",
       recording_url="http://example.com/sample.mp3",
       caller="818011112222")

   if result.errors != None:
       # some error happed
       print json.dumps(result.message, indent=4)
   else:
       callid = result.messages[0]['callid']
       result = xc.get_simple_playback_status(callid)
       print json.dumps(result.message, indent=4)

Explanation

  1. First, you need to create XoxzoClient() object. You must provide xoxzo sid and auth_token when initializing this object. You can get sid and auth_token after you sign up the xoxzo account and access the xoxzo dashboard.
  2. Then you can call call_simple_playback() method. You need to provide three parameters.
  • recording_url: URL of the MP3 file you want to palyback.
  • recipient: phone number of the call recipient. This must start with Japanese country code "+81" and follow the E.164 format.
  • caller: this number will be displayed on the recipient device.

This method will return XoxzoResponse object. If XoxzoResponse.errors == None, XoxzoResponse.messages[0]['callid'] is the meesage id that you can pass to the get_sms_delivery_status() call.

  1. You can check the call status by get_simple_playback_status() method. You will provide call-id of the call you want to check.

About

Python client library for Xoxzo Cloud API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%