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

oxf4rvwz  于 12个月前  发布在  Maven
关注(0)|答案(1)|浏览(214)

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

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

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

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-mybusiness</artifactId>
<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依赖。下面是我所做的:

String accessToken = "your_access_token";

        // Construct the URL
        String url = "https://mybusiness.googleapis.com/v4/accounts/" + ACCOUNT_ID + 
                     "/locations/" + LOCATION_ID + "/reviews/" + REVIEW_ID;

            // Create an instance of OkHttpClient
            OkHttpClient client = new OkHttpClient();
    
            // Build the request, adding the required headers
            Request request = new Request.Builder()
                    .url(url)
                    .addHeader("Authorization", "Bearer " + accessToken)
                    .build();
    
            // Execute the request
            try (Response response = client.newCall(request).execute()) {
                // Check if the response was successful
                if (response.isSuccessful() && response.body() != null) {
                    // Extract the response body as a string
                    String responseBody = response.body().string();
                    System.out.println(responseBody);
                } else {
                    // If the response was not successful, handle it appropriately
                    System.out.println("Response not successful: " + response);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

字符串

相关问题