保利威文档中心

幫助中心

查詢頻道打賞設定

更新時間:2023-03-15 10:54:26

介面說明

1、获取全局或当前生效的打赏设置
2、接口支持https协议

介面URL

http://api.polyv.net/live/v3/channel/donate/get

請求方式

GET

介面限制

1、介面同時支援HTTP及HTTPS,建議使用HTTPS以確保介面安全,介面呼叫有頻率限制,詳細請查看

請求參數說明

參數名 必填 類型 說明
appId true String 帳號appId【詳見取得金鑰
timestamp true Long 目前13位毫秒級時間戳記,3分鐘內有效
sign true String 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己的伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則
channelId false String 頻道號,不傳則為取得全域設定,否則為目前生效設定

範例

http://api.polyv.net/live/v3/channel/donate/get?appId=frlr1zazn3&sign=C2C75D35056DFC64E6678D705FFB1857&channelId=2149710&timestamp=1621844001298

回應參數說明

參數名 類型 說明
code Integer 回應狀態碼,200為成功回傳,非200為失敗【詳見全域錯誤說明
status String 回應狀態文字資訊
message String 回應描述資訊,當code為400或500時,輔助描述錯誤原因
data Object 打賞設定的詳細資訊 【詳見data欄位說明

data欄位說明

參數名 類型 說明
globalSettingEnabled String 是否套用全域設定,取得全域設定時,該值為null
Y:套用全域設定
N:套用頻道設定
donateCashEnabled String 現金打賞開關
donateGoodEnabled String 道具打賞開關
donateTips String 打賞提示
cashMin Double 最低打賞金額
cashes Double[] 打賞金額選項
goods Array 打賞道具選項 【詳見goods欄位說明
donatePointEnabled String 積分打賞開關
pointUnit String 積分打賞單位

goods欄位說明

參數名 類型 說明
goodName String 道具選項名稱
goodImg String 道具選項對應的圖片
goodPrice Float 道具選項對應的價格,單位元
goodEnabled String 是否啟用該道具

Java請求範例

快速接入基礎程式碼請下載相關依賴原始碼點擊下載原始碼,下載後加入到自己的原始碼工程中即可。測試案例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。

強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、例外處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。

private static final Logger log = LoggerFactory.getLogger(PageInteractionTest.class);
/**
 * 查询频道打赏设置
 * @throws IOException
 */
@Test
public void testDonateGet() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v3/channel/donate/get";
    String channelId = "2149710";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);

    requestMap.put("channelId",channelId);

    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url,requestMap);
    log.info("测试查询频道打赏设置接口返回值:{}",response);
    //do somethings
}

回應範例

系統全域錯誤說明詳見全域錯誤說明

成功範例

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "globalSettingEnabled": "Y",
        "donateCashEnabled": "Y",
        "donateGoodEnabled": "Y",
        "donateTips": "打赏",
        "cashMin": 0.01,
        "donatePointEnabled": "N",
        "pointUnit": null,
        "cashes": [0.88, 6.66, 8.88, 18.88, 66.60, 88.80],
        "goods": [{
            "goodName": "鲜花",
            "goodImg": "//s1.videocc.net/default-img/donate/flower.png",
            "goodPrice": 0.00,
            "goodEnabled": "Y"
        }, {
            "goodName": "咖啡",
            "goodImg": "//s1.videocc.net/default-img/donate/coffee.png",
            "goodPrice": 0.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "点赞",
            "goodImg": "//s1.videocc.net/default-img/donate/like.png",
            "goodPrice": 1.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "掌声",
            "goodImg": "//s1.videocc.net/default-img/donate/handclap.png",
            "goodPrice": 2.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "666",
            "goodImg": "//s1.videocc.net/default-img/donate/666.png",
            "goodPrice": 6.66,
            "goodEnabled": "Y"
        }, {
            "goodName": "小星星",
            "goodImg": "//s1.videocc.net/default-img/donate/star.png",
            "goodPrice": 9.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "钻石",
            "goodImg": "//s1.videocc.net/default-img/donate/diamond.png",
            "goodPrice": 19.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "跑车",
            "goodImg": "//s1.videocc.net/default-img/donate/car.png",
            "goodPrice": 29.99,
            "goodEnabled": "Y"
        }, {
            "goodName": "火箭",
            "goodImg": "//s1.videocc.net/default-img/donate/rocket.png",
            "goodPrice": 66.66,
            "goodEnabled": "Y"
        }]
    }
}

異常範例

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询