setUpdatableMsg.md 5.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
消息相关 /动态消息 /修改动态消息

# 修改动态消息

> 接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。

> 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0`

## 接口说明

### 接口英文名

setUpdatableMsg

### 功能描述

该接口用于修改被分享的动态消息。详见[动态消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share/updatable-message.html)

## 调用方式

### HTTPS 调用

```text
POST https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=ACCESS_TOKEN 
```

### 云调用

- 出入参和 HTTPS 调用相同,调用方式可查看[云调用说明文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)
- 接口方法为: openapi.updatableMessage.setUpdatableMsg

### 第三方调用

- 调用方式以及出入参和 HTTPS 相同,仅是调用的 token 不同
- 该接口所属的权限集 id 为:18
- 服务商获得其中之一权限集授权后,可通过使用[authorizer_access_token](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html)代商家进行调用

## 其他说明

### target_state 的合法值

| 值   | 说明   |
| :--- | :----- |
| 0    | 未开始 |
| 1    | 已开始 |

### name 的合法值

| 值           | 说明                                                         |
| :----------- | :----------------------------------------------------------- |
| member_count | `target_state = 0` 时必填,文字内容模板中 `member_count` 的值 |
| room_limit   | `target_state = 0` 时必填,文字内容模板中 `room_limit` 的值  |
| path         | `target_state = 1` 时必填,点击「进入」启动小程序时使用的路径。 对于小游戏,没有页面的概念,可以用于传递查询字符串(query),如 `"?foo=bar"` |
| version_type | `target_state = 1` 时必填,点击「进入」启动小程序时使用的版本。 有效参数值为:`develop`(开发版),`trial`(体验版),`release`(正式版) |

### 消息状态

消息有两个状态(target_state),分别有其对应的文字内容和颜色。文字内容模板和颜色不支持变更。

| 状态 | 文字内容                                            | 颜色    | 允许转移的状态 |
| :--- | :-------------------------------------------------- | :------ | :------------- |
| 0    | "成员正在加入,当前 {member_count}/{room_limit} 人" | #FA9D39 | 0, 1           |
| 1    | "已开始"                                            | #CCCCCC | 无             |

活动的默认有效期是 24 小时。活动结束后,消息内容会变成统一的样式:

- 文字内容:“已结束”
- 文字颜色:`#00ff00`

## 调用示例

> 示例说明: HTTPS调用

### 请求数据示例

```json
{
"activity_id": "966_NGiqxxxxxxxxx...xxxxxxxxE33BlwX", 
"target_state": 0, 
"template_info": {
"parameter_list": [
{"name": "member_count", 
"value": "2"}, 
{"name":"room_limit", 
"value": "5"} 
] 
} 
} 
```

### 返回数据示例

```json
{
"errcode": 0, 
"errmsg": "ok"
} 
```

### 错误码

| 错误码 | 错误码取值                                              | 解决方案                                                     |
| :----- | :------------------------------------------------------ | :----------------------------------------------------------- |
| 40001  | invalid credential access_token isinvalid or not latest | 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 |
| 42001  | access_token expired                                    | access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明 |
| 44002  | empty post data                                         | POST 的数据包为空                                            |
| 47001  | data format error                                       | 解析 JSON/XML 内容错误;post 数据中参数缺失;检查修正后重试。  |
| 47501  | activity_id error                                       | 参数 activity_id 错误                                        |
| 47502  | target_state error                                      | 参数 target_state 错误                                       |
| 47503  | version_type error                                      | 参数 version_type 错误,调整后重试                           |
| 47504  | activity_id expired time                                | activity_id 过期                                             |

|      |      |      |
| :--- | :--- | :--- |
|      |      |      |
|      |      |      |
|      |      |      |