Skip to content

获取登录二维码(Step 2) ​

生成微信登录二维码,返回 wId 和 qrCodeUrl。用户扫码后调 执行微信登录(Step 3) 确认登录。

什么时候调用

只有把微信登录流程集成到自己后台时才需要调 Step 1–3。用 Eyun 控制台登录的,直接在「微信执行实例」添加实例并扫码。

接口地址: POST /iPadLogin

设备类型 ​

类型说明微信要求验证时建议
ipad不影响手机端和电脑端微信使用人脸验证:iPhone 用 安盾 APP,安卓手机用 扫码网关,取码前先装好推荐
mac电脑端微信可能被挤下线默认由平台自动完成,见 Step 3 的 autoCheck仅在业务确认需要时使用

WARNING

  • 掉线重登时,wcId 和 deviceType 必须与上次登录保持一致。
  • 首次登录新设备时,手机端可能弹出验证确认,需要继续调用 执行微信登录(Step 3) 处理。

代理选择 ​

每次生成二维码都必须指定一种登录网络,且只能三选一:proxy、自定义代理、aid。

方式参数适用场景注意事项
平台网络代理proxy希望按省份选择平台线路必选其一
Aid 本地代理aid需要使用本地网络登录必选其一;登录期间 Aid 工具必须一直运行
自定义代理proxyIp + proxyUser + proxyPassword使用自有 Socks5 代理必选其一;代理需要稳定可访问

不要同时传多种网络参数。若同时传入,可能导致登录网络不符合预期。

平台网络代理线路 ​

编号地区编号地区编号地区
1北京11江西21黑龙江
2天津12山东22辽宁
3上海13河南23贵州
4重庆14湖北24广西
5河北15湖南25宁夏
6山西16广东26青海
7江苏17海南27甘肃
8浙江18四川28西藏
9安徽19云南29吉林
10福建20陕西30内蒙古

Aid 本地代理 ​

使用 aid 前,先启动 Aid 节点。按场景选:Windows 桌面环境用 Windows 版;想让出口贴近家庭宽带或移动网络、或 Mac 模式需要扫验证二维码时用 Android 版;需要 7×24 固定出口时部署 Linux 节点。

方式适合场景入口
Windows 版 Aid客服电脑、运营电脑、门店电脑、家用电脑下载 Windows 64 位 Aid
Android 版 AidAndroid 手机或 Android 设备,兼做 Mac 登录验证查看 Android 版 Aid
Linux 版 Aid同城市服务器、家用电脑、自购盒子、虚拟机查看 Aid 本地代理部署

TIP

Linux 节点不建议部署在普通云服务器。云服务器出口 IP、带宽质量和登录城市经常不贴近账号常用环境,容易造成扫码异常或掉线。

代理注意事项

  • 若平台线路不包含你所在城市,且无法使用 Aid 本地代理,请使用自定义代理。
  • 自定义代理传入后如返回“网络链接异常”,请先验证代理 IP、端口、账号、密码是否可用。
  • 若扫码后手机显示的登录地区与预期不符,请联系客服排查线路。

请求参数 ​

参数名必选类型说明
wcId是string微信 ID。首次登录传 "";掉线重登传上次返回的 wcId
deviceType是string设备类型:ipad 推荐;mac 会影响电脑端微信登录状态
proxy三选一int平台网络代理线路编号。选择平台代理时传入
proxyIp三选一string自定义代理 IP + 端口。选择自定义代理时传入
proxyUser三选一string自定义代理账号。选择自定义代理时传入
proxyPassword三选一string自定义代理密码。选择自定义代理时传入
aid三选一stringAid 本地代理编号,可由 Windows / Android / Linux 版本提供。选择 Aid 时传入,登录期间必须保持 Aid 工具运行

请求示例 ​

首次登录,用平台代理:

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

{
  "wcId": "",
  "deviceType": "ipad",
  "proxy": 16
}
bash
curl -X POST '{BASE_URL}/iPadLogin' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wcId": "",
  "deviceType": "ipad",
  "proxy": 16
}'
python
import requests

url = "{BASE_URL}/iPadLogin"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wcId": "",
  "deviceType": "ipad",
  "proxy": 16
}"""

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}/iPadLogin";
String body = "{\n" +
    "  \"wcId\": \"\",\n" +
    "  \"deviceType\": \"ipad\",\n" +
    "  \"proxy\": 16\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}/iPadLogin';
$body = <<<'JSON'
{
  "wcId": "",
  "deviceType": "ipad",
  "proxy": 16
}
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;

掉线后重新登录:wcId 填上次返回的微信 ID,网络方式照样要填:

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

{
  "wcId": "wxid_6tn88z16x6ou12",
  "deviceType": "ipad",
  "proxy": 16
}
bash
curl -X POST '{BASE_URL}/iPadLogin' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wcId": "wxid_6tn88z16x6ou12",
  "deviceType": "ipad",
  "proxy": 16
}'
python
import requests

url = "{BASE_URL}/iPadLogin"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wcId": "wxid_6tn88z16x6ou12",
  "deviceType": "ipad",
  "proxy": 16
}"""

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}/iPadLogin";
String body = "{\n" +
    "  \"wcId\": \"wxid_6tn88z16x6ou12\",\n" +
    "  \"deviceType\": \"ipad\",\n" +
    "  \"proxy\": 16\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}/iPadLogin';
$body = <<<'JSON'
{
  "wcId": "wxid_6tn88z16x6ou12",
  "deviceType": "ipad",
  "proxy": 16
}
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;

改用 Aid 本地代理,把 proxy 换成 aid:

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

{
  "wcId": "",
  "deviceType": "ipad",
  "aid": "703314"
}
bash
curl -X POST '{BASE_URL}/iPadLogin' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wcId": "",
  "deviceType": "ipad",
  "aid": "703314"
}'
python
import requests

url = "{BASE_URL}/iPadLogin"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wcId": "",
  "deviceType": "ipad",
  "aid": "703314"
}"""

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}/iPadLogin";
String body = "{\n" +
    "  \"wcId\": \"\",\n" +
    "  \"deviceType\": \"ipad\",\n" +
    "  \"aid\": \"703314\"\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}/iPadLogin';
$body = <<<'JSON'
{
  "wcId": "",
  "deviceType": "ipad",
  "aid": "703314"
}
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;

改用自定义代理,把 proxy 换成代理地址、账号和密码:

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

{
  "wcId": "",
  "deviceType": "ipad",
  "proxyIp": "121.229.46.245:3829",
  "proxyUser": "proxy-user",
  "proxyPassword": "proxy-password"
}
bash
curl -X POST '{BASE_URL}/iPadLogin' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "wcId": "",
  "deviceType": "ipad",
  "proxyIp": "121.229.46.245:3829",
  "proxyUser": "proxy-user",
  "proxyPassword": "proxy-password"
}'
python
import requests

url = "{BASE_URL}/iPadLogin"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "wcId": "",
  "deviceType": "ipad",
  "proxyIp": "121.229.46.245:3829",
  "proxyUser": "proxy-user",
  "proxyPassword": "proxy-password"
}"""

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}/iPadLogin";
String body = "{\n" +
    "  \"wcId\": \"\",\n" +
    "  \"deviceType\": \"ipad\",\n" +
    "  \"proxyIp\": \"121.229.46.245:3829\",\n" +
    "  \"proxyUser\": \"proxy-user\",\n" +
    "  \"proxyPassword\": \"proxy-password\"\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}/iPadLogin';
$body = <<<'JSON'
{
  "wcId": "",
  "deviceType": "ipad",
  "proxyIp": "121.229.46.245:3829",
  "proxyUser": "proxy-user",
  "proxyPassword": "proxy-password"
}
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": "1000",
  "message": "登录成功",
  "data": {
    "wId": "0000016e-63ef-3a9c-0001-ed3311628ef4",
    "qrCodeUrl": "https://你的接口域名/qrcode/login-aidnet.png"
  }
}

错误响应 ​

json
{
  "code": "1001",
  "message": "网络链接异常",
  "data": null
}

常见失败 ​

失败时 code 为 "1001",原因在 message 里。下面两种只在传了 wcId(掉线重登)时出现:

message原因怎么办
获取二维码频繁,请稍后重试。同一个 wcId 一分钟内取码超过 6 次等一分钟再取
微信已登录,请勿重复获取。这个微信号现在就在线不用重新登录。当前的 wId 可以用查询在线微信列表查到

响应参数 ​

参数名类型说明
codestring1000 成功;其他值都是失败,通常是 1001
messagestring反馈信息
data.wIdstring登录实例标识。每次登录可能变化,请实时保存
data.qrCodeUrlstring二维码图片 URL,用于微信扫码

下一步 ​

扫码后调用 执行微信登录(Step 3),确认登录并保存 wcId。