My Business
1.7K members online now
1.7K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

No results With Google My Business API

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

The example below request the user to authorize my app to manage his business listing,

It works well with the authentication part and the user can see my app in his authorized apps list but I can't get any results when I'm trying to view the accounts list, here is my code:

 

<?php
require_once "vendor/autoload.php";
require_once "MyBusiness.php";
session_start();
$client = new Google_Client();
$client->setAccessType("offline");
$client->setAuthConfig('client_id.json');
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  $client->setAccessToken($_SESSION['access_token']);
  $mybusinessService = new Google_Service_Mybusiness($client);
  $accounts = $mybusinessService->accounts;
  echo json_encode($accounts);
  echo '<br>';
} else {
  $redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . '/gmb_callback.php';
  header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
?>

The json results is null

Can anyone provide a working example to view and manage business listing such as details, review etc ?

1 Expert replyverified_user

No results With Google My Business API

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

I'm being ignored and I have no idea why

Re: No results With Google My Business API

Google Employee
# 3
Google Employee

Hi @Shlomi S,

 

You need to request user consent at least once for each Google Account you need to access the Google My Business data from. The end users will have to log in with their Google Accounts to manually authorize the application using OAuth 2.0 Authorization. They need to perform this process only once with an OAuth 2.0 client ID during the OAuth 2.0 installed application flow, OAuth 2.0 web server application flow (your other OAuth 2.0 client ID web app).

 

Since the PHP client library doesn’t currently support the display of detailed error messages, you should follow the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

Thanks,

The Google My Business API Team