获取打赏设置

接口URL

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

接口说明

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

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号,不传为获取全局设置,否则为当前生效设置

响应成功JSON示例:

{
  "code": 200,
  "status": "success",
  "message": "",
  "data": {
    "globalSettingEnabled": "N",
    "donateCashEnabled": "Y",
    "donateGoodEnabled": "Y",
    "donateTips": null,
    "cashMin": 0,
    "cashes": [
      0.88,
      6.66,
      8.88,
      18.88,
      66.6,
      88.8
    ],
    "goods": [
      {
        "goodName": "鲜花",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/01-flower.png",
        "goodPrice": 0,
        "goodEnabled": "Y"
      },
      {
        "goodName": "咖啡",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/02-coffee.png",
        "goodPrice": 0.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "点赞",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/03-good.png",
        "goodPrice": 1.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "掌声",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/04-applaud.png",
        "goodPrice": 2.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "666",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/05-666.png",
        "goodPrice": 6.66,
        "goodEnabled": "Y"
      },
      {
        "goodName": "小星星",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/06-star.png",
        "goodPrice": 9.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "钻石",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/07-diamond.png",
        "goodPrice": 19.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "跑车",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/08-car.png",
        "goodPrice": 29.99,
        "goodEnabled": "Y"
      },
      {
        "goodName": "火箭",
        "goodImg": "//livestatic.videocc.net/uploaded/images/webapp/channel/donate/09-rocket.png",
        "goodPrice": 66.66,
        "goodEnabled": "Y"
      }
    ]
  }
}

响应失败JSON示例:

未输入appId

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

appId不正确

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

时间戳错误

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

签名错误

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

字段说明

参数名 说明
code 返回状态码,成功为200,参数错误为400。
status 状态,成功返回success,失败返回error
message 错误提示信息,成功时为空串
data 打赏设置的相关信息
globalSettingEnabled 是否应用全局设置,获取全局设置时,该值为null
donateCashEnabled 现金打赏开关
donateGoodEnabled 道具打赏开关
donateTips 打赏提示
cashMin 最低打赏金额
cashes 打赏金额选项
goods 打赏道具选项
goodName 道具选项名
goodImg 道具选项对应的图片
goodPrice 道具选项对应的价格
goodEnabled 是否启用该道具

php请求示例

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

$channelId="206016";

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

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

$url = "http://api.polyv.net/live/v3/channel/donate/get?".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);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...