# 设置用户微信分享自定义URL接口

### 接口URL

```
https://api.polyv.net/live/v3/user/set-weixin-share-api
```

### 接口说明

```
设置用户自定义的微信分享接口地址
```

### 支持格式

```
JSON
```

### 请求方式

```
POST
```

### 请求参数

| 参数名       | 必选   | 类型及范围  | 说明                                                                                                                                                                                                        |
| --------- | ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sign      | 是    | 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位当前时间的时间戳                                                                                                                                                                                               |
| url       | true | string | 接口地址URL                                                                                                                                                                                                   |

### 返回错误结果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": ""
}
```

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

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": "success"
}
```

返回结果data表示成功修改的数量.

### 字段说明

| 字段      | 类型及范围  | 说明   |
| ------- | ------ | ---- |
| code    | int32  | 返回码  |
| status  | string | 返回状态 |
| message | string | 返回信息 |
| data    | string | 操作结果 |

### PHP请求示例

```php
<?php

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

//接口需要的参数（非sign）赋值
$appId = "XXXXXXXX";
$timestamp = "123123123123";
$url = "http://www.polyv.ne/xxx";
$params = array(
		'appId'=>$appId,
		'url'=>$url,
		'timestamp'=>$timestamp
	);

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

$url = "https://api.polyv.net/live/v3/user/set-weixin-share-api?".http_build_query($params);

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


---

# 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/f1a945501c45f36106bbac48a2c4da72.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.
