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

yipeiwu_com6年前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设计】。

相关文章

Python-Seaborn热图绘制的实现方法

Python-Seaborn热图绘制的实现方法

制图环境: pycharm python-3.6 Seaborn-0.8 热图 import numpy as np import seaborn as sns import...

Python实现基于POS算法的区块链

Python实现基于POS算法的区块链

区块链中的共识算法 在比特币公链架构解析中,就曾提到过为了实现去中介化的设计,比特币设计了一套共识协议,并通过此协议来保证系统的稳定性和防攻击性。 并且我们知道,截止目前使用最广泛,...

Python将文本去空格并保存到txt文件中的实例

如下所示: #encoding=utf-8# x=raw_input("Please enter a text: ") y=x.replace(" ","") f = open(...

python比较2个xml内容的方法

本文实例讲述了python比较2个xml内容的方法。分享给大家供大家参考。具体分析如下: from xml.etree import ElementTree OK=True ma...

Python中的面向对象编程详解(下)

继承 继承描述了基类的属性如何“遗传”给派生类。一个子类可以继承它的基类的任何属性,不管是数据属性还是方法。 创建子类的语法看起来与普通(新式)类没有区别,一个类名,后跟一个或多个需要...