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

相关文章

python aiohttp的使用详解

python aiohttp的使用详解

1.aiohttp的简单使用(配合asyncio模块) import asyncio,aiohttp async def fetch_async(url): print(url)...

对python多线程与global变量详解

今天早上起来写爬虫,基本框架已经搭好,添加多线程爬取功能时,发现出错: 比如在下载文件的url列表中加入200个url,开启50个线程。我的爬虫…竟然将50个url爬取并全部命名为0.h...

TensorFlow实现AutoEncoder自编码器

TensorFlow实现AutoEncoder自编码器

一、概述 AutoEncoder大致是一个将数据的高维特征进行压缩降维编码,再经过相反的解码过程的一种学习方法。学习过程中通过解码得到的最终结果与原数据进行比较,通过修正权重偏置参数降低...

python将txt文件读取为字典的示例

如下所示: # -*- coding: utf-8 -*- # @Time :18-8-2 下午3:23 import sys reload(sys) sys.setdefault...

Python类中方法getitem和getattr详解

1、getitem 方法 使用这个方法最大的印象就是调用对象的属性可以像字典取值一样使用中括号['key'] 使用中括号对对象中的属性进行取值、赋值或者删除时,会自动触发对应的__g...