Live Streaming Mini Program Development
Main Interface of the Mini Program:



Preparation Before Development
- In the WeChat Developer backend for the mini program, go to Settings - Development Settings - Server Domain Names and configure the [request legal domain name].

- In the WeChat Developer backend for the mini program, go to Settings - Interface Settings and enable the switches for real-time audio/video streaming and real-time audio/video recording.

API Description
API 1: Get Push URL
API URL
https://live.polyv.net/api/v2/teacher_login.json
Request Method
POST
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| passwd | true | string | md5(channel password) |
| sign | true | string | Signature |
| timestamp | true | string | Current 13-digit millisecond timestamp |
| number | true | string | Channel number |
| account | true | string | Channel number |
Rules
passwd rule: md5(password) Example: password(channel password): 461666 passwd = md5(461666) = aeb0e56d32d841cbc52b0ed18721167e
sign rule: md5("live.polyv.net" + channelId + passwd + timestamp) Example: channelId:153884 passwd: aeb0e56d32d841cbc52b0ed18721167e timestamp: 1516327146366 sign = md5(live.polyv.net153884aeb0e56d32d841cbc52b0ed18721167e1516327146366) sign = 32046e6a4bab8d95de9e5bc6fc4630e7
Field explanation required after a successful request:
{
url: "rtmp://push2.videocc.net/recordfe/" //推流域名
stream:"16ad889b3d20180118174258966" //流名
}
Push URL retrieval rule: url + stream; Example: rtmp://push2.videocc.net/recordfe/16ad889b3d20180118174258966
API 2: Set Channel Name
API URL
https://api.live.polyv.net/v1/channels/{channelId}/update
Request Method
POST
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | string | Name to modify |
| sign | true | string | Signature |
| ptime | true | string | Current 13-digit millisecond timestamp |
| channelId | true | string | Channel number |
Rules
Uppercase MD5 value: "APPCHANNELSET" + "channelId=" + channelId + "name=" + name + "APPCHANNELSET"
Example: str = APPCHANNELSETchannelId=153884name=小程序推流测试testAPPCHANNELSET Md5(str) = 03395ed7f948a6f8cc63a5eeba21ccb7 Note: Convert to uppercase sign = 03395ED7F948A6F8CC63A5EEBA21CCB7
Return result
{
status: "success",
result: "update channel successfully"
}
API 3: Get Chat Room Audience Count
API URL
https://api.chat.polyv.net/front/listUsers
Request Method
GET
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| roomId | true | string | Channel number |
Return result
{
count: 0, //在线人数
userlist: [] //在线用户列表
}
