/business/community?hl=en
This content is likely not relevant anymore. Try searching or browse recent questions.
Unable to connect MyBusiness with google-api-php-client. 1 Recommended Answer 1 Reply 0 Upvotes
1 Recommended Answer
$0 Recommended Answers
1 Relevant Answer
$0 Relevant Answers
Hi, m newbie with google API and stuck into a typical situation.
I am building a php based centralized admin area where admin can see all his business locations, reviews, ratings etc.
I am using google-api-php-client and some-how I manage to install it with composer. the login pert went well and i have successfully store user token to DB (for future access).
 
require './google_sdk/vendor/autoload.php'; $client = new Google_Client(); $client->addScope(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/books', 'https://www.googleapis.com/auth/plus.business.manage')); $client->setAccessType('offline'); $client->setAuthConfigFile('./google_sdk/client_secret.json'); $client->setDeveloperKey(gp_DeveloperKey); /*- defined -*/ if($_SESSION['google_access_token']!=NULL && $_SESSION['google_access_token']!=""){ $client->setAccessToken($_SESSION['google_access_token']); try{ $activeAct=$_REQUEST['act']!=""?$_REQUEST['act']:'feeds'; switch($activeAct){ case "feeds": include_once("google_feeds.php"); break; case "reports": include_once("google_reports.php"); break; default: echo '<h3 align="center">Error Occured</h3>'; break; } }catch(Exception $e){ echo "<pre>"; print_r($e->getMessage()); echo "</pre>"; exit();
} }else{ $client->setRedirectUri($URL.'social_report.php?tab=gp'); if(isset($_GET['code']) && $_GET['code']!="" ){ $client->authenticate($_GET['code']); $_SESSION['google_access_token'] = $client->getAccessToken(); @mysql_query("UPDATE `user` SET `user_gp_token`='".$_SESSION['google_access_token']."' WHERE `user_id`='".$_SESSION["user_id"]."'; "); ?> <script> window.location="<?=$URL.'social_report.php?tab=gp'?>"; </script> <?php }else{ $auth_url = $client->createAuthUrl(); ?> <div class="row text-center" style="margin:80px 0px;"> <a href="<?=$auth_url?>"> <img src="img/sign-in-google.png" alt="Google Login" /> </a> </div> <?php }

And, it successfully accessing "google_feeds.php".
 
FYI, Above code is working and asking permission for all four Scopes ( 'auth/books' is used for testing ans it is working and returning data). Project ID approved for MyBusiness API access from google end.
 
Now, in google_feeds.php I am trying to call the "Google_Service_Mybusiness", for that purpose i downloaded 'google-api-services-mybusiness-v3-php-rev-20160505-1' from GIT and paste the 'Mybusiness.php' to 'google_sdk/vendor/google/apiclient/src/Google/Service/'.
 
Please check the 'google_feeds.php':
 
require './google_sdk/vendor/google/apiclient/src/Google/Service/Mybusiness.php'; $Oauth2Service = new Google_Service_Oauth2($client); $user = $Oauth2Service->userinfo->get(); $gmbService = new Google_Service_Mybusiness($client); $results = $gmbService->accounts->listAccounts(); echo "<pre>"; print_r($results); echo "</pre>";
 
And it is Catching the error:
 
Also, I have tried with 'https://developers.google.com/oauthplayground/' but it also returning error:
{ "error": { "status": "NOT_FOUND", "message": "Method not found.", "code": 404 } }
 
Please let me know what i am missing here. Thank you for your time and patience.
Details
Relevant Answer Relevant Answers (0)
This question is locked and replying has been disabled.
Discard post? You will lose what you have written so far.
Write a reply
10 characters required
Failed to attach file, click here to try again.
Discard post?
You will lose what you have written so far.
Personal information found

We found the following personal information in your message:

This information will be visible to anyone who visits or subscribes to notifications for this post. Are you sure you want to continue?

A problem occurred. Please try again.
Create Reply
Edit Reply
Delete post?
This will remove the reply from the Answers section.
Notifications are off
Your notifications are currently off and you won't receive subscription updates. To turn them on, go to Notifications preferences on your Profile page.
Report abuse
Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence. When you submit a report, we'll investigate it and take the appropriate action. We'll get back to you only if we require additional details or have more information to share.

Go to the Legal Help page to request content changes for legal reasons.

Reported post for abuse
Unable to send report.
Report post
What type of post are you reporting?
Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence. When you submit a report, we'll investigate it and take the appropriate action. We'll get back to you only if we require additional details or have more information to share.

Go to the Legal Help page to request content changes for legal reasons.

Reported post for abuse
Unable to send report.
This reply is no longer available.
/business/threads
//accounts.google.com/ServiceLogin
You'll receive email notifications for new posts at
Unable to delete question.
Unable to update vote.
Unable to update subscription.
You have been unsubscribed
Deleted
Unable to delete reply.
Removed from Answers
Marked as Recommended Answer
Removed recommendation
Undo
Unable to update reply.
Unable to update vote.
Thank you. Your response was recorded.
Unable to undo vote.
Thank you. This reply will now display in the answers section.
Link copied
Locked
Unlocked
Unable to lock
Unable to unlock
Pinned
Unpinned
Unable to pin
Unable to unpin
Marked
Unmarked
Unable to mark
Reported as off topic
/business/profile/0