[英]How to programmatically get the version of an app on Huawei AppGallery?
我知道如何為 Google Play 商店完成此操作(在此處回答) ,但我沒能找到 AppGallery 的方法。 謝謝!
更新 #1
使用下面的答案,我通過以下步驟部分解決了這個問題:
查詢應用程序信息的響應有很多關於應用程序的信息,包括“versionNumber”,但對我來說它不提供“versionNumber”(我需要的單一信息),因為這個參數是可選的。 現在我又被卡住了,因為我不明白我需要改變什么才能收到這個。
如果有人知道我該如何解決這個問題,非常感謝您的幫助。
更新 #2
@shirley 的評論是正確的。 該問題已在他們的最新版本中得到修復,並已於本月發布。
您可以撥打查詢應用信息電話API(GET方式)查詢應用詳情:
public static void getAppInfo(String domain, String clientId, String token, String appId, String lang) {
HttpGet get = new HttpGet(domain + "/publish/v2/app-info?appid=" + appId + "&lang=" + lang);
get.setHeader("Authorization", "Bearer " + token);
get.setHeader("client_id", clientId);
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse httpResponse = httpClient.execute(get);
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
BufferedReader br =
new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), Consts.UTF_8));
String result = br.readLine();
// Object returned by the app information query API, which can be received using the AppInfo object. For details, please refer to the API reference.
JSONObject object = JSON.parseObject(result);
System.out.println(object.get("ret"));
}
} catch (Exception e) {
}
}
我知道如何為 Google Play 商店(在此處回答)做到這一點,但我沒有設法找到 AppGallery 的方法。 謝謝!
更新#1
使用下面的答案,我通過以下步驟部分解決了這個問題:
Querying App Information 的響應有很多關於應用程序的信息,包括“versionNumber”,但對我來說,它不提供“versionNumber”(我需要的單個信息),因為這個參數是可選的。 現在我又被卡住了,因為我不明白我需要改變什么才能收到這個。
如果有人知道我如何解決這個問題,非常感謝您的幫助。
更新#2
@shirley 的評論是對的。 該問題已在其最新版本中得到修復,並已於本月發布。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.