admin
2022-04-07 211840b64fa1132d76d6dff6c779e9ba2c0c450f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.yeshi.utils;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
import java.net.URLEncoder;
 
/**
 * 应用市场帮助类
 */
public class AppMarketUtil {
 
    /**
     * 获取应用的最新版本
     *
     * @param appId
     * @return
     */
    public static String getHWLatestVersion(String appId) {
        try {
            String url = String.format("https://appgallery.cloud.huawei.com/uowap/index?method=internal.getTabDetail&serviceType=13&reqPageNum=1&uri=%s&appid=C%s&shareTo=undefined&locale=en_US&maxResults=10&currentUrl=%s&version=10.0.0", URLEncoder.encode("app|C" + appId, "UTF-8"), appId, URLEncoder.encode(String.format("https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C%s", appId), "UTF-8"));
            System.out.println(url);
            String result = HttpUtil.get(url);
            JSONObject root = JSONObject.fromObject(result);
            JSONArray array = root.optJSONArray("layoutData");
            for (int i = 0; i < array.size(); i++) {
                JSONObject item = array.optJSONObject(i);
                if (item != null && item.optJSONArray("dataList") != null) {
                    JSONArray array1 = item.optJSONArray("dataList");
                    if (array1 != null)
                        for (int j = 0; j < array1.size(); j++) {
                            item = array1.optJSONObject(j);
                            if (item != null && !StringUtil.isNullOrEmpty(item.optString("version"))) {
                                return item.optString("version").trim();
                            }
                        }
                }
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 获取vivo最新的版本号
     *
     * @param appId
     * @return
     */
    public static Integer getVIVOLatestVersionCode(String appId) {
        try {
            String url = String.format("https://hf.appstore.vivo.com.cn/detail/%s?frompage=messageh5&imei=1234567890&av=18&app_version=2100&pictype=webp&h5_websource=h5appstore", appId);
            System.out.println(url);
            String result = HttpUtil.get(url);
            JSONObject root = JSONObject.fromObject(result);
            return root.optInt("version_code");
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
}