python 控制Asterisk AMI接口外呼电话的例子

yipeiwu_com7年前Python基础

Asterisk 是一个开放源代码的软件VoIP PBX系统,我们用Asterisk 搭建企业内部电话系统。

Asterisk AMI的Asterisk管理接口。可以实现对Asterisk系统的监控和控制。

安装 asterisk-ami

pip install asterisk-ami

pip install git+https://github.com/ettoreleandrotognoli/python-ami

源码

#!/usr/bin/env python
#-*- coding: utf-8 -*-
from asterisk.ami import AMIClient
from asterisk.ami import SimpleAction
 
 
def CallSip(exten,ponebind,callid):
 client = AMIClient(address='10.200.22.79', port=5038)
 client.login(username='lucal',secret='test')
 sip='SIP/%s'%ponebind
 print (sip)
 action = SimpleAction(
  'Originate',
  Channel=sip,
  Exten=callid,#目标电话
  Priority=1,
  Context='MAIN_OUTGOING',#呼叫规则
  CallerID=exten,#来自电话
 )
 client.send_action(action)
 future = client.send_action(action)
 response = future.response
 
 
if __name__ == '__main__':
 exten='2100'
 ponebind='2100'
 callid='2101'
 CallSip(exten, ponebind, callid)

以上这篇python 控制Asterisk AMI接口外呼电话的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

浅析PyTorch中nn.Linear的使用

浅析PyTorch中nn.Linear的使用

查看源码 Linear 的初始化部分: class Linear(Module): ... __constants__ = ['bias'] def __init__(s...

介绍Python中的__future__模块

Python的每个新版本都会增加一些新的功能,或者对原来的功能作一些改动。有些改动是不兼容旧版本的,也就是在当前版本运行正常的代码,到下一个版本运行就可能不正常了。 从Python 2....

python的移位操作实现详解

因为要将js的一个签名算法移植到python上,遇到一些麻烦。 int无限宽度,不会溢出 算法中需要用到了32位int的溢出来参与运算,但是python的int是不会溢出的,达到界限后...

Python配置文件处理的方法教程

Python配置文件处理的方法教程

前言 在平时的工程中,我们在构建工程时,常常需要用到配置文件,用来配置项目的一些信息,比如数据库,请求网址,文件夹,线程、进程数等信息,这样就可以方便我们通过修改配置文件中的参数来很好地...

tensorflow ckpt模型和pb模型获取节点名称,及ckpt转pb模型实例

ckpt from tensorflow.python import pywrap_tensorflow checkpoint_path = 'model.ckpt-8000'...