什么是谷歌我的企业V4 API的maven依赖,以阅读评论?

oxf4rvwz  于 2024-01-06  发布在  Maven
关注(0)|答案(1)|浏览(316)

使用这个文档accounts.locations.reviews.get我试图阅读JAVA 18中的具体评论,问题是我没有找到这个旧API的Maven依赖项,它还没有被弃用。
在我以前

  1. MyBusiness.Accounts.Locations.Reviews.Get myReview= mybusiness.accounts().locations().reviews().get(reviewName);
  2. Review response=myReview.execute();

字符串
现在连我都不能初始化API了!
我尝试在pom.xml中添加:
x1c 0d1x的数据

  1. <dependency>
  2. <groupId>com.google.apis</groupId>
  3. <artifactId>google-api-services-mybusiness</artifactId>
  4. <version>v4-rev20211101-1.32.1</version>

但它不接受,并有一个错误:
缺少构件com.google.apis:google-api-services-mybusiness:jar:v4-rev 20211101 -1.32.1
我能做什么?

1dkrff03

1dkrff031#

我发现了另一种方法来获得评论,使用OkHttp客户端设置对Google My Business API的请求,但我仍然有兴趣知道什么是Maven依赖。下面是我所做的:

  1. String accessToken = "your_access_token";
  2. // Construct the URL
  3. String url = "https://mybusiness.googleapis.com/v4/accounts/" + ACCOUNT_ID +
  4. "/locations/" + LOCATION_ID + "/reviews/" + REVIEW_ID;
  5. // Create an instance of OkHttpClient
  6. OkHttpClient client = new OkHttpClient();
  7. // Build the request, adding the required headers
  8. Request request = new Request.Builder()
  9. .url(url)
  10. .addHeader("Authorization", "Bearer " + accessToken)
  11. .build();
  12. // Execute the request
  13. try (Response response = client.newCall(request).execute()) {
  14. // Check if the response was successful
  15. if (response.isSuccessful() && response.body() != null) {
  16. // Extract the response body as a string
  17. String responseBody = response.body().string();
  18. System.out.println(responseBody);
  19. } else {
  20. // If the response was not successful, handle it appropriately
  21. System.out.println("Response not successful: " + response);
  22. }
  23. } catch (Exception e) {
  24. e.printStackTrace();
  25. }

字符串

展开查看全部

相关问题