1. 宁卫微信通信模块使用说明书:
  2. 宁卫通信
  3. 新闻动态
  4. 宁卫新闻
  5. 宁卫微信通信模块使用说明书

宁卫微信通信模块使用说明书

https://mp.weixin.qq.com/s/JzPMakWoCQyPbDN7o8QP6Q

需要开通有关音视频流的权限

协议

如何让微信小程序和传统电话进行语音沟通、进行实时交流

 协议部分

 

 双向的协议

 

请求包

```

{

       "type":"request",

       "method":"x",                        //register,invite,bye,cancel,answer,option,message

       "version":"x",                       //1.0,1.1 等,高版本可支持低版本,但低版本不一定支持高版本

       "sessionid":"x",                     //invite,bye,cancel,answer 需在同一个会话中

       "order":x,                           //序号

       "appname":"x",                       //如微信小程序

       "protoname":"x",                     //rtmp gb28181 rtsp

       "realm":"x",                         //实际ip

       "data":{

              "caller_number":"x",                    //都有

              "callee_number":"x",                    //register,option没有

              "caller_url":"x",                       //推流地址

              "callee_url":"x",                       //拉流地址

              "caller_audio":"G711A",                 //推流语音编码

              "caller_video":"H264" ,                 //推流视频编码

              "media_attribute":"x",                  //sendonly,sendrecv,recvonly

              "password":"x"                          //密码,只在register时启用

       }

}

```

 

回应包

 

```

{

       "type":"response",

       "method":"x",

       "version":"x",                       //1.0,1.1 等,高版本可支持低版本,但低版本不一定支持高版本

       "sessionid":"x",                     //invite,bye,cancel,answer 需在同一个会话中

       "order":x,                           //序号

       "appname":"x",                       //wx,fs,摄像机

       "protoname":"x",                     //rtmp gb28181 rtsp

       "data":{

              "code":"200ok",                      //200 401 403 480,解析不了 505506请求类型不配套

              "msg":"xxx"                          //回应的消息内容

              "callee_audio":"G711A",                //推流语音编码

              "callee_video":"H264" ,                 //推流视频编码

              "caller_url":"x",                       //推流地址

              "callee_url":"x"                        //拉流地址

       }

}

```

 

 模块配置

 

```

[server]

addr=0.0.0.0:18123

welcome_wav=/opt/welcome.wav

welcome_h264=/opt/welcome.h264

fs_esl_ip=127.0.0.1:8021

fs_auth=ClueCon

 

base_pull_url=rtmp://182.61.34.55/live/

base_push_url=rtmp://182.61.34.55/live/

 

use_callout=false

callout_gateway=

 

[user]

user_number=2

 

[users]

user1=lihao

password1=1234

user2=nway

password2=1234

 

 

#this not support

[database]

use_db=no

#yes no

#posgresql,mysql,sqlite3

db_type=sqlite3

db_string=./db.db3

 

#sqlite3

#/*

#create table wx_user(

#     user_name text,

#     password text

#)

#*/

#postgresql

#/*

#create table wx_user(

#     user_name text,

#     password text

#)

#*/

#mysql

#/*

#create table wx_user(

#     user_name text,

#     password text

#)

#*/

 

 

#this not support

[acl]

use_acl=no

allow=0.0.0.0

```

## 使用方法

 

### 加载模块

 

```

load mod_nway_wx

```

 

api 规则

```

nway_wx_api uuid caller_name gateway destination_number welcome.wav welcome.h264 rtmp://nway.com.cn/push_url rtmp://nway.com.cn/pull_url nway.com.cn

```

 

呼叫规则

 

    由小程序发起呼叫,可以呼给手机,也可以直接呼给座席终端,可以启用视频,也可以不启用视频,如果用在语音系统中,不建议使用视频,否则带宽占用比较大

 

模块配置

 

```

<configuration name="nway_wx.conf" description="nway wx service control module for FreeSWITCH">

  <settings>

    <param name="ip_port" value="0.0.0.0:25535"/>

    <param name="use_video" value="false"/>

    <param name="audio_codec" value="aac"/>

    <param name="video_codec" value="h264"/>

    <param name="push_to_other" value="true"/>

    <param name="program_name" value="wechat"/>

    <!--program name usage: wechat dingding douyin hd-machine-->

    <param name="use_flv" value="true"/>

    <param name="ptime" value="20"/>

  </settings>

</configuration>

```

 

UI

在小程序开发环境中



手机小程序中界面


当按以上的通信协议和使用方式通信时,就能让我们的电话系统和微信直接双通了。