Polyv Help Center

Help Center

Associate Custom Session ID with Live Stream

Updated: 2022-09-02 18:08:07

Interface URL

https://api.polyv.net/live/v3/channel/session/relevance

Interface Description

1、接口用于
2、接口支持https

Supported Format

JSON

Request Method

POST

Request Limit

TRUE

Request Parameters

Parameter Name Required Type Description
appId Yes string Obtained from API settings, the appId registered in the live streaming system
timestamp Yes long Current 13-digit timestamp
sign Yes String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be stored or used directly on the client side. All API calls must be relayed through your own server to the POLYV server to obtain response data. See signature generation rules
channelId Yes int Channel ID
externalSessionId Yes string Custom live session UUID, 32 characters in length

Successful Response JSON Example:

{
  "code": 200, 
  "status": "success", 
  "message": "", 
  "data": "success"
}

Failed Response JSON Examples:

appId not provided

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

Incorrect appId

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

Timestamp error

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

Signature error

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

Field Description

Parameter Description
code Response code: 200 for success, 400 for failure, 401 for signature error, 500 for server error
status "success" for success, "error" for failure
message Error message when status is "error"
data "success" upon successful modification

PHP Request Example

<?php
//引用config.php
include '/srv/http/config.php';

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => '206204',
  'externalSessionId' => '自定义直播场次UUID,32位长度');

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "http://api.polyv.net/live/v3/channel/relevance-session?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>
联系客服,在线咨询