Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 APIs are deprecated #27

Open
mzohaibnaz opened this issue Apr 21, 2022 · 9 comments
Open

v4 APIs are deprecated #27

mzohaibnaz opened this issue Apr 21, 2022 · 9 comments

Comments

@mzohaibnaz
Copy link

hey i'm wondering when we will have new version for this package which will support new google my business apis.

@Coding-007
Copy link

waiting for it :)

@mzohaibnaz
Copy link
Author

this package will no longer work after 30 April, I'm just wondering how long should I wait :)

@Coding-007
Copy link

I have updated my all APIs with new GMB PHP API Clients v1. As well there are some endpoints that are still using v4.9, so for them, I am still using this class.

@basi
Copy link

basi commented May 10, 2022

@Coding-007

Currently in the process of being replaced.
I could not call listLocationsQuestions with a new endpoint.
I am having trouble with the read_mask in the error response because the argument does not exist.

If you know how to solve this problem, please let me know :)

  • composer require "google/apiclient": "2.12.4",
/**
 * Service definition for MyBusinessQA (v1).
 *
 * <p>
 * The My Business Q API allows questions and answers to be posted for specific
 * listings.</p>
 *
 * <p>
 * For more information about this service, see the API
 * <a href="https://developers.google.com/my-business/" target="_blank">Documentation</a>
 * </p>
 *
 * @author Google, Inc.
 */
class MyBusinessQA extends \Google\Service {}
  • sample request
private function _getClient() {
    $config = static::getConfig();

    $client = new \Google\Client();
    $client->setClientId($config['clientId']);
    $client->setClientSecret($config['clientSecret']);
    $client->setRedirectUri($config['redirectUri']);
    $client->addScope($config['scopes']);
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    $client->setState(uuid());
    $client->setApiFormatV2(true);
    $client->setApplicationName('xxx');

    return $client;
}

// My Business Q&A API
// https://console.cloud.google.com/apis/api/mybusinessqanda.googleapis.com/metrics?project=xxx
// https://developers.google.com/my-business/content/qanda/change-log
$service = new MyBusinessQA($this->_getClient());
$locationName = 'xxx/xxx';
return $service->locations_questions->listLocationsQuestions($locationName)->getQuestions();
  • response
2022-05-10 13:54:46 Error: {
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "read_mask",
            "description": "Field is required"
          }
        ]
      }
    ]
  }
}

@Coding-007
Copy link

Read_mask field needs to be sent while fetching resources. Field read_mask is a list of properties against a specific API you want to get. Suppose a listing has a name, title, and address and I have to get the name and title, so I have to send read_mask in which I will mention my desired properties.
Here is a code section from my code.

// import your required class like this, like questions, etc
use Google\Service\MyBusinessBusinessInformation;

$account_name = $account['name'];
$optional_params = [];
$optional_params['pageSize'] = 100;
$optional_params['readMask'] = ['name', 'title', 'storefrontAddress', 'latlng', 'phoneNumbers', 'Metadata'];

$this->gmb_info_service = new MyBusinessBusinessInformation($this->client);
$locations = $this->gmb_info_service->accounts_locations->listAccountsLocations($account_name,$optional_params);

@basi
Copy link

basi commented May 10, 2022

thanks!

MyBusinessBusinessInformation can be called in the same way.
Cannot call My Business Q&A API. Is it possible to retrieve questions and answers?

Also, where can I find a list of readMasks required for each api?

// My Business Q&A API
// https://console.cloud.google.com/apis/api/mybusinessqanda.googleapis.com/metrics?project=xxx
// https://developers.google.com/my-business/content/qanda/change-log

use Google\Service\MyBusinessQA;

$service = new MyBusinessQA($this->_getClient());
$locationName = 'xxx/xxx';
return $service->locations_questions->listLocationsQuestions($locationName)->getQuestions();

@basi
Copy link

basi commented May 11, 2022

thanks!

The conclusion was a bug in google-api-php-client-services.
https://github.com/googleapis/google-api-php-client-services/pull/1010/files
googleapis/google-api-php-client-services#956

@mbrodala
Copy link

Notice that not all MyBusiness APIs have counterparts in the new MyBusinessInformation API, e.g. location reviews. For these this package is still necessary and works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants