Browse Source

feat(淘宝转链): aiopen 接口 shortLinkurl/deeplink 改用淘口令中的 m.tb.cn 链接

dodo hold 1 day ago
parent
commit
ba24b47bed
1 changed files with 13 additions and 4 deletions
  1. 13 4
      molilian.core/Plus/Alimama/parse_endpoint/endpoint_aiopen.cs

+ 13 - 4
molilian.core/Plus/Alimama/parse_endpoint/endpoint_aiopen.cs

@@ -26,8 +26,8 @@ namespace molilian.core
                 string pid = _account.open_pid?.Trim() ?? string.Empty;
 
 #if DEBUG
-                accessKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUTUNQIiwic3ViIjoiTExNX0FHRU5UOlBMQVRGT1JNOnVuaW9uLWFpLWdhdGV3YXk6VU5HV185NjkyNTIyNzIzX3VJQ1RsOERHIiwiaWF0IjoxNzg2MzY5NTc0LCJqdGkiOiIyMjUwZWMyOC04MDg2LTQwNTktODVjZi02NTYxNmZhZDU4MDUifQ.8ThEiO3aXMfzCS8gSk0d22hlK8rpqMxhUNMpQU6DZn0";
-                pid = "mm_9692522723_3372850009_116175250382";
+                //accessKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJUTUNQIiwic3ViIjoiTExNX0FHRU5UOlBMQVRGT1JNOnVuaW9uLWFpLWdhdGV3YXk6VU5HV185NjkyNTIyNzIzX3VJQ1RsOERHIiwiaWF0IjoxNzg2MzY5NTc0LCJqdGkiOiIyMjUwZWMyOC04MDg2LTQwNTktODVjZi02NTYxNmZhZDU4MDUifQ.8ThEiO3aXMfzCS8gSk0d22hlK8rpqMxhUNMpQU6DZn0";
+                //pid = "mm_9692522723_3372850009_116175250382";
 #endif
 
                 if (string.IsNullOrEmpty(accessKey) || string.IsNullOrEmpty(pid))
@@ -239,8 +239,10 @@ namespace molilian.core
                 result.reason = string.Empty;
                 result.subCode = TkSubCodeEnum.Success;
                 result.content = ReplaceUrls(content, shortLinkurl);
-                result.shortLinkurl = shortLinkurl;
-                result.deeplink_url = GetDeeplink(shortLinkurl);
+                // 优先使用完整淘口令中的 m.tb.cn 链接,没有则保留 s.click 短链
+                string tpwdUrl = ExtractAiOpenTpwdUrl(fullTpwd);
+                result.shortLinkurl = string.IsNullOrEmpty(tpwdUrl) ? shortLinkurl : tpwdUrl;
+                result.deeplink_url = GetDeeplink(result.shortLinkurl);
                 result.taoToken = string.IsNullOrEmpty(fullTpwd)
                     ? $"{shortTpwd} {shortLinkurl}".Trim()
                     : fullTpwd;
@@ -373,6 +375,13 @@ namespace molilian.core
                     || value.TryGetProperty("resultCode", out _));
         }
 
+        private static string ExtractAiOpenTpwdUrl(string fullTpwd)
+        {
+            if (string.IsNullOrEmpty(fullTpwd)) return string.Empty;
+            Match match = Regex.Match(fullTpwd, @"https?://m\.tb\.cn/[^\s]+", RegexOptions.IgnoreCase);
+            return match.Success ? match.Value : string.Empty;
+        }
+
         private static string ReadAiOpenErrorDescription(JsonElement value, string fallback)
         {
             string description = value.Read("bizErrorDesc", string.Empty);