> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/unclassified/2021/f51bb22cc1d73e2dab03e2d73ef564ab.md).

# 获取多频道定时抽奖状态的接口

### 接口URL

```
http://api.polyv.net/live/v3/channel/lottery/get-rooms-status
```

### 接口说明

```
1.获取多频道定时抽奖状态
2.接口支持https
```

### 请求方式

```
GET
```

### 请求参数

| 参数名        | 必选   | 类型及范围  | 说明                                                                                                                                                                                                        |
| ---------- | ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sign       | true | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |
| appId      | true | string | 开发者账号下的appId                                                                                                                                                                                              |
| timestamp  | true | string | 13位当前时间的时间戳                                                                                                                                                                                               |
| channelIds | true | string | 频道号。多个用英文逗号隔开                                                                                                                                                                                             |

### 返回错误结果JSON示例

```json
签名错误：
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
时间戳错误：
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
appId错误
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
应用找不到
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
频道号错误
{
    "code": 400,
    "status": "error",
    "message": "channelIds is required.",
    "data": ""
}
```

### 返回正确结果JSON示例

```json
{
    "code":200,
    "status":"success",
    "message":"",
    "data":[
        {
            "roomId":"2437051",
            "status":3,
            "time":0
        },
        {
            "roomId":"2442336",
            "status":3,
            "time":0
        }
    ]
}
```

### 字段说明

| 字段             | 类型及范围  | 说明                       |
| -------------- | ------ | ------------------------ |
| code           | int    | 接口请求状态码，200表示成功          |
| status         | string | 接口请求状态，"success"表示成功     |
| message        | string | 请求失败时返回的错误信息             |
| data           | array  |                          |
| data\[].roomId | string | 频道号                      |
| data\[].status | int    | 抽奖状态，0倒计时，1抽奖中，2已结束，3已关闭 |
| data\[].time   | int    | 定时剩余时间，单位毫秒              |

### PHP请求示例

```php
<?php

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

$channelIds = "322120,2029098";
$params = array(
        'appId'=>$appId,
        'channelIds'=>$channelIds,
        'timestamp'=>$timestamp
    );

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

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

$ch = curl_init() or die ( curl_error() );
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 360);
$response = curl_exec ( $ch );
curl_close ( $ch );
echo $response;
?>

```
