保利威文档中心

幫助中心

查詢頻道正在進行某個互動

更新時間:2022-09-02 18:08:07

介面URL

https://api.polyv.net/live/v3/chat/inConductInteractive

介面說明

查詢某個頻道是否正在進行互動動作(簽到、問卷、抽獎、正在答題等)

支援格式

JSON

請求方式

GET

請求參數

參數名 必填 類型及範圍 說明
sign true String 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則
appId true string appId
timestamp true string 13位時間戳
channelId true string 頻道號

回傳結果

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "sign": true,
        "lottery": false,
        "questionnaire": false,
        "testQuestions": false
    }
}

失敗回傳json(不帶jsonp)

//时间搓过期
{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}
//签名错误
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

欄位說明

欄位名稱 說明
code 回應代碼,成功為200,失敗為400,簽名錯誤為403,異常錯誤500(http狀態碼也跟code相同)
status 成功為success,失敗為error
message 錯誤時為錯誤提示訊息
data 成功時回傳一個物件,內容為下面欄位
sign 是否正在簽到
lottery 是否正在抽獎
questionnaire 是否正在問卷
testQuestions 是否正在答卷

php請求範例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => 195770
);

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

$url = "https://api.polyv.net/live/v3/chat/inConductInteractive?".http_build_query($params);

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

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