Create Inviter
API Description
1、邀请海报-创建邀请者
2、appId、timestamp、sign必须通过url传递
3、接口支持https协议
API URL
http://api.polyv.net/live/v4/channel/invite/poster/create
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Watch page link access method:
https://live.polyv.cn/watch/{channelId}?invitePosterId={invitePosterId}For example:https://live.polyv.cn/watch/3121680?invitePosterId=4fdb2496, Invited users can access this link via WeChat to complete the invitation binding. Invitation detail data can be obtained through the "Query Invitation Poster Detail Data" API.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. Only query parameters participate in signing See Signature Generation Rules |
| channelId | true | String | Channel ID |
| openId | true | String | Inviter user ID |
| nickname | true | String | Inviter nickname |
| avatar | false | String | Inviter avatar URL. If empty, the default avatar is used |
| viewerId | false | String | Inviter viewer ID |
| invitee | false | String | Custom invitation ID |
Example
http://api.polyv.net/live/v4/channel/invite/poster/create?appId=frlr1zazn3×tamp=1653556311000&channelId=3121680&sign=959D476D141DC170E0118DCC43839101&openId=jiangyifana&nickname=%E5%B8%86%E7%83%A6%E5%8F%8D%E9%A5%AD
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by the business. Returns success on success, error on failure |
| success | Boolean | Whether the response is successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only used for troubleshooting and debugging, should not be tied to business logic |
| error | Object | Error information when status code is not 200 See Error Field Description |
| data | Object | See data Field Description |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to determine the specific error reason |
| desc | String | Error description, corresponding to error.code |
data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| invitePosterId | String | Invitation poster ID |
| channelId | Integer | Channel ID |
| openId | String | Inviter user ID |
| invitee | String | Custom invitation ID |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API functionality integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 创建邀请者
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void inviterCreateTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/invite/poster/create";
String channelId = "3121680";
String openId = "1yexRmHZoJrcw40";
String nickname = "张三";
String viewerId = "UPpuW43RFIKSveD";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("openId", openId);
requestMap.put("nickname", nickname);
requestMap.put("viewerId", viewerId);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postFormBody(url, null);
log.info("测试创建邀请者成功:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "2a8712050df1475db89fbb9348efc035.65.16541338429926329",
"data": {
"invitePosterId": "2325308f",
"channelId": 3121680,
"openId": "1yexRmHZoJrcw40",
"invitee": null
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
