Skip to content
POST{BASE_URL}/api/contact/batchOpenidToUserid
只读联系人JSON · Bearer 调用凭证 · body appid

批量 openid 转 userid ​

把一批 openid 转回 userid。

说明与注意 ​

  • corpAppId 必须和转出这批 openid 时用的企业应用相同。

请求参数 ​

参数必填类型说明
appid是string实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx
openIdList是array<string>要转换的 openid 列表。示例:["wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"]
openPartyIdList否array<string>部门 openid 列表;没有就传空数组 [],不要传 null。示例:[]
corpAppId是int64企业应用 id(大写 I),取自同步企业应用列表的 metaList[].appId;不能用内置的「微信联系人」应用 5629500422244800,会返回 -7320007|。示例:5629500000000001

请求示例 ​

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

{
  "appid": "we_xxxxxxxxxxxxxxx",
  "openIdList": [
    "wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"
  ],
  "openPartyIdList": [],
  "corpAppId": 5629500000000001
}
bash
curl -X POST '{BASE_URL}/api/contact/batchOpenidToUserid' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "appid": "we_xxxxxxxxxxxxxxx",
  "openIdList": [
    "wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"
  ],
  "openPartyIdList": [],
  "corpAppId": 5629500000000001
}'
python
import requests

url = "{BASE_URL}/api/contact/batchOpenidToUserid"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "appid": "we_xxxxxxxxxxxxxxx",
  "openIdList": [
    "wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"
  ],
  "openPartyIdList": [],
  "corpAppId": 5629500000000001
}"""

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}/api/contact/batchOpenidToUserid";
String body = "{\n" +
    "  \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
    "  \"openIdList\": [\n" +
    "    \"wmAbCdEfGhIjKlMnOpQrStUvWxYz0123\"\n" +
    "  ],\n" +
    "  \"openPartyIdList\": [],\n" +
    "  \"corpAppId\": 5629500000000001\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}/api/contact/batchOpenidToUserid';
$body = <<<'JSON'
{
  "appid": "we_xxxxxxxxxxxxxxx",
  "openIdList": [
    "wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"
  ],
  "openPartyIdList": [],
  "corpAppId": 5629500000000001
}
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
{
  "code": 0,
  "data": {
    "openidList": [
      {
        "vid": 7881300000000001,
        "openid": "wmAbCdEfGhIjKlMnOpQrStUvWxYz0123"
      }
    ]
  },
  "detail": "",
  "message": "ok",
  "time": "2026-11-10 18:34:09"
}

响应字段 ​

字段类型说明
codeint64统一封套状态码:0=成功,负数=失败
dataobject转换结果
data.openidListarray<object>每项对应 openIdList 里的一个
data.openidList[].vidint64转换后的 userid
data.openidList[].openidstring请求里的 openid
detailstring附加明细,通常为空
messagestring文案:成功为 ok;失败形如 -码|描述
timestring服务端处理时间 YYYY-MM-DD HH:MM:SS

下一步 ​