voximplant api客户端库

voximplant-apiclient的Python项目详细描述


先决条件

为了使用Vox植入Python SDK,您需要如下:

  1. 开发人员帐户。如果你没有的话,sign up here
  2. 一个私有api密钥。有两个选项可供选择:
    1. Voximplant Control panel
    2. 中生成它
    3. 或者使用指定的authentication parameters调用CreateKeyhttp api方法。您将收到一个包含result字段的响应。将result值保存在文件中(因为我们不存储密钥,所以请将其安全地保存在您的一侧)。
  3. python 2.x或3.x运行时,安装了pipsetuptools>;=18.5

如何使用

转到项目文件夹并使用pip

安装sdk
python -m pip install --user voximplant-apiclient

然后在脚本中导入sdk

fromvoximplant.apiclientimportVoximplantAPI

接下来,在构造函数中或使用环境中指定json服务帐户文件的路径。

构造函数

api=VoximplantAPI("/path/to/credentials.json")

env

exportVOXIMPLANT_CREDENTIALS=/path/to/credentials.json

示例

开始一个场景

fromvoximplant.apiclientimportVoximplantAPI,VoximplantExceptionif__name__=="__main__":api=VoximplantAPI("credentials.json")# Start a scenario of the user 1RULE_ID=1SCRIPT_CUSTOM_DATA="mystr"USER_ID=1try:res=api.start_scenarios(RULE_ID,script_custom_data=SCRIPT_CUSTOM_DATA,user_id=USER_ID)print(res)exceptVoximplantExceptionase:print("Error: {}".format(e.message))

发送短信

fromvoximplant.apiclientimportVoximplantAPI,VoximplantExceptionif__name__=="__main__":api=VoximplantAPI("credentials.json")# Send the SMS with the "Test message" text from the phone number 447443332211 to the phone number 447443332212SOURCE="447443332211"DESTINATION="447443332212"SMS_BODY="Test message"try:res=api.send_sms_message(SOURCE,DESTINATION,SMS_BODY)print(res)exceptVoximplantExceptionase:print("Error: {}".format(e.message))

获取通话记录项

fromvoximplant.apiclientimportVoximplantAPI,VoximplantExceptionimportpytzimportdatetimeif__name__=="__main__":api=VoximplantAPI("credentials.json")# Get the first call session history record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTCFROM_DATE=datetime.datetime(2012,1,1,0,0,0,pytz.utc)TO_DATE=datetime.datetime(2014,1,1,0,0,0,pytz.utc)COUNT=1try:res=api.get_call_history(FROM_DATE,TO_DATE,count=COUNT)print(res)exceptVoximplantExceptionase:print("Error: {}".format(e.message))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在依赖项上没有这样的方法异常   java如何将@Value注入setter?   验证输入java的最佳实践   java在使用kotlin的安卓项目中没有此类字段错误   我们可以强制java接口实现超时吗?   java将BasicAuth()与FormLogin()组合用于不同的路径   java无法在更新SDK后更新应用程序(未安装应用程序)   macos Java 8、Swing和OSX:对话框使UI对鼠标无响应   java自定义单元格格式以US格式显示,尽管使用了带UK语言环境的DataFormatter   java按升序排列列表字符串数据   java Hibernate OGM[PersistenceUnit:person]无法构建Hibernate SessionFactory   生命周期配置未涵盖java插件执行:com。乱穿马路。专家插件。安卓generation2:安卓mavenplugin:3.5.0:generatesources   java RecyclerView显示为空   当服务器不返回任何输入时,java InputStream read()会阻塞