# 更新应用信息

### 接口URL

```
https://api.polyv.net/live/v2/app/update
```

### 接口说明

```
1、接口用于创建应用
2、接口支持https
```

### 支持格式

```
JSON
```

### 请求方式

```
POST
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名                | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| ------------------ | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId              | 是  | string | 管理员的appId                                                                                                                                                                                                 |
| timestamp          | 是  | long   | 13位当前时间戳                                                                                                                                                                                                  |
| sign               | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |
| userId             | 是  | string | 应用ID                                                                                                                                                                                                      |
| name               | 否  | string | 应用名称                                                                                                                                                                                                      |
| watchDomain        | 否  | string | 自定义观看页域名                                                                                                                                                                                                  |
| webappDomain       | 否  | string | 自定义管理后台域名                                                                                                                                                                                                 |
| logoImg            | 否  | string | 自定义管理后台的图标地址                                                                                                                                                                                              |
| coverImg           | 否  | string | 自定义管理后台的封面图片地址                                                                                                                                                                                            |
| concurrences       | 否  | int    | 应用的并发数                                                                                                                                                                                                    |
| **appEnglishName** | 否  | string | 应用英文名称                                                                                                                                                                                                    |

### 响应成功JSON示例：

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "appId": "fbj0k74n6s",
        "name": "test-ccb-3",
        "appSecret": "9a9c4badcecd42dc82131f229d07fd04",
        "userId": "a6580a9674",
        "appEnglishName": "testEnglish"
    }
}
```

### 响应失败JSON示例：

未输入appId

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

appId不正确

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

时间戳错误

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

签名错误

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

### 字段说明

| 参数名                     | 说明                                  |
| ----------------------- | ----------------------------------- |
| code                    | 响应代码，成功为200，失败为400，签名错误为401，异常错误500 |
| status                  | 成功为success，失败为error                 |
| message                 | 错误时为错误提示消息                          |
| data                    | 成功响应时为相关的应用信息                       |
| data.appId              | 应用所属的调用POLYV的appId                  |
| data.appSecret          | 应用所属的调用POLYV的appSecret              |
| data.name               | 应用名称                                |
| data.userId             | 应用ID，对应于POLYV的用户ID                  |
| **data.appEnglishName** | 应用英文名称                              |

### php请求示例

```php
<?php
//引用config.php
include '/srv/http/config.php';
$params = array(
  'appId' => $appId,
  'userId' => $userId,  
  'name' => $name,
  'watchDomain' => $watchDomain,
  'webappDomain' => $webappDomain,
  'logoImg' => $logoImg,
  'coverImg' => $coverImg,
  'concurrences' => $concurrences,  
  'timestamp' => $timestamp
);

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

$url = "https://api.polyv.net/live/v2/app/update?".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;
?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/unclassified/2019/4394ba012a13e885dd9dd238006c2161.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
