简体   繁体   中英

How to programmatically get the version of an app on Huawei AppGallery?

I know how it can be done for Google Play Store (answer here) , but i didn't manage to find a way for AppGallery. Thank you!

UPDATE #1

Using the answer below i partially solve this with this steps:

  1. Make an API Client with Administrator role, it also works with App Administrator and Operations. (documentaion here: API Client )
  2. Get the access token. (documentaion here: Obtaining a Token )
  3. Get app info. (documentaion here: Querying App Information )

The response from the Querying App Information, have a lot of informations about the app including "versionNumber", but for me it doesn't provide the "versionNumber" (the single info i needed), because this parameter is optional. And now i am stuck again, because i don't understand what i need to change in order to receive this one.

If anyone knows how I can solve this, thank you very much for your help.

UPDATE #2

@shirley's comment was right. The issue has been fixed in their latest release, and it has been released this month.

You can call the Querying App Information API (GET mode) to query the app details:

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) {
     }
 }

They are mentioned here: Completing App Information , Querying App Information .

I know how it can be done for Google Play Store (answer here) , but i didn't manage to find a way for AppGallery. Thank you!

UPDATE #1

Using the answer below i partially solve this with this steps:

  1. Make an API Client with Administrator role, it also works with App Administrator and Operations. (documentaion here: API Client )
  2. Get the access token. (documentaion here: Obtaining a Token )
  3. Get app info. (documentaion here: Querying App Information )

The response from the Querying App Information, have a lot of informations about the app including "versionNumber", but for me it doesn't provide the "versionNumber" (the single info i needed), because this parameter is optional. And now i am stuck again, because i don't understand what i need to change in order to receive this one.

If anyone knows how I can solve this, thank you very much for your help.

UPDATE #2

@shirley's comment was right. The issue has been fixed in their latest release, and it has been released this month.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM