|
|
@@ -268,9 +268,12 @@ public class TrackingController {
|
|
|
// S2S架构:腾讯服务器回调,真实用户IP通过参数传递,优先使用参数中的IP
|
|
|
String paramIp = params.get("ip");
|
|
|
device.put("ip", (paramIp != null && !paramIp.isBlank()) ? paramIp : clientIp(request));
|
|
|
- // 优先使用真实设备UA,无则使用默认UA
|
|
|
+ // 优先使用真实设备UA,无则根据平台构造合理的移动设备UA
|
|
|
String ua = firstParam(params, "ua", "user_agent", "useragent");
|
|
|
- device.put("ua", (ua != null && !ua.isBlank()) ? ua : AdxClient.BAIDU_USER_AGENT);
|
|
|
+ if (ua == null || ua.isBlank()) {
|
|
|
+ ua = defaultMobileUa(resolved.platform());
|
|
|
+ }
|
|
|
+ device.put("ua", ua);
|
|
|
device.put("deviceType", 1);
|
|
|
int os = baiduOsForPlatform(resolved.platform());
|
|
|
if (os != 0) device.put("os", os);
|
|
|
@@ -314,6 +317,15 @@ public class TrackingController {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ /** 根据平台返回合理的移动设备UA,确保百度能识别为真实手机请求 */
|
|
|
+ private static String defaultMobileUa(String platform) {
|
|
|
+ if ("ios".equals(platform)) {
|
|
|
+ return "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1";
|
|
|
+ }
|
|
|
+ // 默认Android
|
|
|
+ return "Mozilla/5.0 (Linux; Android 14; Pixel 8 Build/UQ1A.240205.002) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.71 Mobile Safari/537.36";
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, Object> baiduUidFromParams(Map<String, String> p) {
|
|
|
Map<String, Object> uid = new LinkedHashMap<>();
|
|
|
putUid(uid, "did", firstParam(p, "did", "imei"));
|