|
|
@@ -188,6 +188,7 @@ public class LoginServiceImpl implements LoginService {
|
|
|
}
|
|
|
|
|
|
// 使用手机号获取凭证换取手机号
|
|
|
+ // 根据微信官方文档,access_token应该在URL参数中
|
|
|
String url = String.format(
|
|
|
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s",
|
|
|
accessToken
|
|
|
@@ -198,8 +199,12 @@ public class LoginServiceImpl implements LoginService {
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Content-Type", "application/json");
|
|
|
+ headers.set("Accept", "application/json");
|
|
|
HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestBody, headers);
|
|
|
|
|
|
+ log.info("[微信API] 请求获取手机号 - phoneCode: {}",
|
|
|
+ phoneCode != null ? phoneCode.substring(0, Math.min(10, phoneCode.length())) + "..." : "null");
|
|
|
+
|
|
|
// 使用postForObject并手动解析JSON,避免Content-Type问题
|
|
|
String response = restTemplate.postForObject(url, entity, String.class);
|
|
|
log.info("[微信API] 获取手机号响应 - response: {}", response);
|