googleapis / google-api-php-client-services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URGENT: GoogleMyBusiness API: v4.9 removed completely, although documentation still supports some endpoints that haven't been replaced yet

nekromoff opened this issue · comments

See:
https://developers.google.com/my-business/reference/rest/v4/accounts.locations/reportInsights

Also:
https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews

And a couple of other endpoints are missing.

These endpoints have not been replaced by the new v1 API so far, but they have been completely removed from the PHP code base, so the service usage is completely hindered.

Probably it wasn't part of this library before either, but this should be included in the services until the API is completely available under new v1:
https://developers.google.com/my-business/samples/google-api-services-mybusiness-v4p9-php-rev-20210224-1.zip

Actually, v4.9 (linked) does not work either, weird errors such as

Path locations/XXXXXXXXXXXXXXXXXXXXX does not match any known templates

given. Path is correct per API docs here:
https://developers.google.com/my-business/reference/rest/v4/accounts.locations/reportInsights

It seems to me that former v4.9 API is completely broken without existing replacement opposite to what documentation says. Thanks Google devs.

Are you sure about that? I'm currently using both resources you mentioned above and they are working as expected.

See when this was posted. They have fixed the library since.

However 4.9 endpoints have been completely removed without replacement. That is still outstanding issue. Try to get reviews and insights. Good luck.

I'm using them like I mentioned above - getting reviews and insights in 4.9, as they are not marked as deprecated thus not available in any other API.

My bad, version I'm using is 4.8, but I can see here https://developers.google.com/my-business/samples/previousVersions#v49 that listAccountsLocationsReviews, updateReply, reportInsights etc. are present.

I have added the existing v4.9 endpoints as a helper to my tool. I am posting the code, maybe it helps someone.

class GMBHelper
{

    /** v4.9 working 02/2022 **/
    public static function listReviews($client, $params, $account, $location)
    {
        $response = $client->authorize()->get('https://mybusiness.googleapis.com/v4/' . $account . '/' . $location . '/reviews', ['query' => $params]);
        return json_decode((string) $response->getBody(), false);
    }

    /** v4.9 working 02/2022 **/
    public static function reportInsights($client, $params, $account)
    {
        try {
            $response = $client->authorize()->post('https://mybusiness.googleapis.com/v4/' . $account . '/locations:reportInsights', [
                \GuzzleHttp\RequestOptions::JSON => $params,
            ]);
        } catch (\GuzzleHttp\Exception\RequestException $ex) {
            return $ex->getResponse()->getBody()->getContents();
        }
        return json_decode((string) $response->getBody(), false);
    }

    /** v1 replacement for non-working "readMask" required error, but this endpoint does not require readMask **/
    public static function listQuestions($client, $location, $params)
    {
        try {
            $response = $client->authorize()->get('https://mybusinessqanda.googleapis.com/v1/' . $location . '/questions', ['query' => $params]);
        } catch (\GuzzleHttp\Exception\RequestException $ex) {
            return $ex->getResponse()->getBody()->getContents();
        }
        return json_decode((string) $response->getBody(), false);
    }

}

The page you linked to contains the previous version. This library is generated entirely from endpoints published by the API teams themselves (in this case, the mybusinessQA discovery doc. So if those endpoints don't exist in the current version, it was a decision by the current API team to not support those API endpoints in the current version. Unfortunately I cannot speak to why this decision was made, but this is Working As Designed.

Still the same bump and API calls completely missing that are valid calls as mentioned in the reference (v4.9 leftovers):
https://developers.google.com/my-business/reference/rest/v4/accounts.locations.localPosts

Hi Google Api Team, any update in this task i have issue with Insights and other endpoints

This client library only publishes the most recent version of any of our APIs as defined by that API's Discovery JSON. MyBusiness is referencing a discovery document at https://mybusiness.googleapis.com/$discovery/rest?version=v4 in their API reference documentation, but unfortunately that URL is unreachable.

I've filed an internal issue with their team to try and track down what happened. In the meantime, if there's a previous version of this library which supports MyBusiness, you could use that. Unfortunately, looking through our past releases, I cannot find evidence that a MyBusiness API client was EVER generated in this repository.

If you look at our release two years ago (before our last clean-up), we support the same services for the MyBusiness APIs that we do today. So I am confused where "v4.9 removed completely" comes from. If we could find these classes in the Repo history, we can add them back.

Old endpoints still work and client library was never in this repo (there was a direct download link for php file 😆).

@eldair Any update on this task, I continue with the issue at times to try downloading the location Insights Report(accounts.locations.reportInsights)

@adrianlaraperez88 I'm not a maintainer here, I just added my opinion on this :/
regarding accounts.locations.reportInsights (which still works) there is now a replacement endpoint (locations.getDailyMetricsTimeSeries), but it is very lacking (only one metric per request and a bunch of metrics are removed)

For anyone interested, this is the My Business PHP classes I downloaded from google couple of years ago for old endpoints (still works) https://gist.github.com/Eldair/e52c09331a4f33a4370013dcb1b05a1d

Old endpoints still work and client library was never in this repo (there was a direct download link for php file 😆).

Well, that explains a lot. No wonder we're having so many issues.

For anyone interested, this is the My Business PHP classes

It would be possible to host these somewhere separate (such as bshaffer/google-mybusiness-client) so that those who need it can use it. For now, anyone coming here can download and include the files in their code using @eldair's link above.

I've added a package bshaffer/apiclient-mybusiness-service, which is just the previous package, but added back to packagist so you can pull it down and use it. You can see the repo here: https://github.com/bshaffer/google-mybusiness-php-client

Use it as follows:

composer require bshaffer/apiclient-mybusiness-service

And then in your code:

require 'vendor/autoload.php';

$client = new Google\Client;
$mybusiness = new Google_Service_MyBusiness($client);
$response = $mybusiness->accounts_locations_reviews->listAccountsLocationsReviews('accounts/foo/locations/bar');

I'm closing this because I think there is no better solution, as the discovery document (which is used by this repo) has been removed.