totalvoice node
Versão 1.12.0
nodejs的客户totalvoice api
功能
要求
安装
npm install --save totalvoice-node或者
yarn add totalvoice-node使用
要使用此库,您必须首先在“总语音网站”上注册。创建注册后,将提供访问API的访问权限。
借助访问权限,可以根据API文档进行咨询/注册
可以调用的API方法:
以下有关如何使用此库的示例。
在两个数字之间打电话:A和B
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . ligar ( "4832830151" , "4811111111" )
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; 通过ID致电咨询
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . buscar ( 123 ) // ID da chamada
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; 关闭一个主动电话
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . encerrar ( 123 ) // ID da chamada
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; SMS运输
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
var resposta_usuario = false ;
var multi_sms = false ;
var data_criacao = '' ;
client . sms . enviar ( "4811111111" , "Mensagem SMS" , resposta_usuario , multi_sms , data_criacao )
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; TTS运输
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
var opcoes = { velocidade : 2 , tipo_voz : "br-Vitoria" , bina : "bina_cadastrada" } ;
client . tts . enviar ( "4811111111" , "Mensagem TTS" , opcoes ) ;
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; 音频提交
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . audio . enviar ( "4811111111" , "https://foo.bar/audio.mp3" )
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; 中央电话设置
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . central . buscaRamal ( 123546 ) // ID do Ramal
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; 帐户数据管理
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . conta . buscar ( 123546 ) // ID da Conta
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; 平衡我的帐户
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . perfil . consultaSaldo ( )
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; 如果您需要使用自己的语音总配置的地址
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" , "https://seu-dominio.com.br" ) ;
...如果您需要与代理使用
const totalvoice = require ( 'totalvoice-node' ) ;
let options = {
proxy : {
host : 'proxy.com' ,
port : 8888 ,
auth : {
username : 'XXXX' ,
password : 'XXXX'
}
}
} ;
const client = new totalvoice ( "access-token" , "https://seu-dominio.com.br" , options ) ;
...有关可用方法的更多信息,请参见API文档
贡献!
想贡献吗?点击这里
执照
该库遵循麻省理工学院的使用条款