Skip to content

撤回消息 ​

撤回当前微信实例发出的消息。

接口地址: POST /revokeMsg

说明与注意 ​

  • msgId、newMsgId、createTime 都在发送接口的返回里,发送成功时就存下来,撤回时直接用。
  • 超过微信的撤回时限会失败,别的实例发的消息也撤不了。

请求参数 ​

参数名必选类型说明
wId是string登录实例标识
wcId是string接收方微信 ID/群 ID
msgId是long消息 ID,发送类接口返回
newMsgId是long新消息 ID,发送类接口返回
createTime是long发送时间戳,发送类接口返回

请求示例 ​

http
POST {BASE_URL}/revokeMsg
Authorization: Bearer <你的调用凭证>
Content-Type: application/json

{
 "wId": "12491ae9-62aa-4f7a-83e6-9db4e9f28e3c",
 "wcId": "wxid_1dfgh4fs8vz22",
 "msgId": 697760203,
 "newMsgId": 4792296942111367533,
 "createTime": 1641456307
}
bash
curl -X POST '{BASE_URL}/revokeMsg' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
 "wId": "12491ae9-62aa-4f7a-83e6-9db4e9f28e3c",
 "wcId": "wxid_1dfgh4fs8vz22",
 "msgId": 697760203,
 "newMsgId": 4792296942111367533,
 "createTime": 1641456307
}'
python
import requests

url = "{BASE_URL}/revokeMsg"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
 "wId": "12491ae9-62aa-4f7a-83e6-9db4e9f28e3c",
 "wcId": "wxid_1dfgh4fs8vz22",
 "msgId": 697760203,
 "newMsgId": 4792296942111367533,
 "createTime": 1641456307
}"""

resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

String url = "{BASE_URL}/revokeMsg";
String body = "{\n" +
    " \"wId\": \"12491ae9-62aa-4f7a-83e6-9db4e9f28e3c\",\n" +
    " \"wcId\": \"wxid_1dfgh4fs8vz22\",\n" +
    " \"msgId\": 697760203,\n" +
    " \"newMsgId\": 4792296942111367533,\n" +
    " \"createTime\": 1641456307\n" +
    "}";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
    .header("Authorization", "Bearer <你的调用凭证>")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
php
<?php

$url = '{BASE_URL}/revokeMsg';
$body = <<<'JSON'
{
 "wId": "12491ae9-62aa-4f7a-83e6-9db4e9f28e3c",
 "wcId": "wxid_1dfgh4fs8vz22",
 "msgId": 697760203,
 "newMsgId": 4792296942111367533,
 "createTime": 1641456307
}
JSON;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer <你的调用凭证>',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

成功响应 ​

json
{
 "message": "成功",
 "code": "1000",
 "data": null
}

错误响应 ​

json
{
 "message": "失败",
 "code": "1001",
 "data": null
}

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
datanull无业务数据返回