【发布时间】:2019-11-08 21:09:54
【问题描述】:
我可以连接到“Google 我的商家”并拨打电话以返回帐号,但我无法列出与该帐户关联的位置,进而无法检索评论。
require_once( '/functions/google-api-php-client/vendor/autoload.php' );
require_once( '/functions/mybusiness/MyBusiness.php' );
$client = new Google_Client();
if ( $credentials_file = checkServiceAccountCredentialsFile() ) {
// set the location manually
$client->setAuthConfig( $credentials_file );
} elseif ( getenv( 'GOOGLE_APPLICATION_CREDENTIALS' ) ) {
// use the application default credentials
$client->useApplicationDefaultCredentials();
} else {
echo missingServiceAccountDetailsWarning();
return;
}
$client->setApplicationName( "Cardall_Orthodontics_Reviews" );
$client->setScopes( [ 'https://www.googleapis.com/auth/plus.business.manage' ] );
$service = new Google_Service_Mybusiness( $client );
$accounts = $service->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
$account = $accountsList[0];
$locations = $service->accounts_locations;
$locationsList = $locations->listAccountsLocations( $account->name )->getLocations(); // This is where it's not returning the locations
$location = $locationsList[0];
$reviews = $service->accounts_locations_reviews;
$listReviewsResponse = $reviews->listAccountsLocationsReviews( $location->name );
$reviewsList = $listReviewsResponse->getReviews();
当我打印 $account->name 时,我可以看到 accounts/000000000000000000000(带有我的帐户 ID)所以我只是假设它在此之前一直在工作,但我不确定为什么不会有任何地点。我在“我的商家”帐户中添加了一个。
【问题讨论】:
-
您找到解决方案了吗?我有同样的问题
-
对我来说也是同样的问题。 Keith 或@EmilioGort 你有解决方案吗?
-
很遗憾,我从未找到解决方案。
标签: php google-my-business-api