Google MyBusiness API PHP位置

Google MyBusiness API PHP位置,php,google-api,google-api-php-client,service-accounts,google-my-business-api,Php,Google Api,Google Api Php Client,Service Accounts,Google My Business Api,这是我第一次遇到Google MyBusiness API。 我试图检索帐户位置,但什么也没有 我没有直接访问帐户的权限,我的客户让我通过json文件访问API $client=new Google_client(); $client->useApplicationDefaultCredentials(); $client->addScope('https://www.googleapis.com/auth/plus.business.manage'); $service=新谷歌服务\我的业务(

这是我第一次遇到Google MyBusiness API。 我试图检索帐户位置,但什么也没有

我没有直接访问帐户的权限,我的客户让我通过json文件访问API

$client=new Google_client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/plus.business.manage');
$service=新谷歌服务\我的业务($client);
$accounts=$service->accounts->listcounts();
我没有任何错误,只要
Google\u Service\u MyBusiness\u list accounts response
对象,然后在该对象上提供
foreach
,我就可以获得帐户信息:

object(Google_Service_MyBusiness_Account)[94]
  protected 'internal_gapi_mappings' => 
    array (size=0)
      empty
  public 'accountName' => null
  public 'accountNumber' => null
  public 'name' => string 'accounts/XXXXXXXXXXXXXXXXXXXXX' (length=30)
  protected 'organizationInfoType' => string 'Google_Service_MyBusiness_OrganizationInfo' (length=42)
  protected 'organizationInfoDataType' => string '' (length=0)
  public 'permissionLevel' => null
  public 'profilePhotoUrl' => string '.../photo.jpg' (length=94)
  public 'role' => null
  protected 'stateType' => string 'Google_Service_MyBusiness_AccountState' (length=38)
  protected 'stateDataType' => string '' (length=0)
  public 'type' => string 'PERSONAL' (length=8)
  protected 'modelData' => 
    array (size=0)
      empty
  protected 'processed' => 
    array (size=0)
      empty
  public 'state' => 
    object(Google_Service_MyBusiness_AccountState)[84]
      protected 'internal_gapi_mappings' => 
        array (size=0)
          empty
      public 'status' => string 'UNVERIFIED' (length=10)
      protected 'modelData' => 
        array (size=0)
          empty
      protected 'processed' => 
        array (size=0)
          empty

现在,当我尝试:

$name=$account->getName()//账户/XXXXXXXXXXXXXX
$service->accounts\u locations->listaccounts位置($name);
我得到的几乎是空的
Google\u Service\u MyBusiness\u ListLocationsResponse
对象:

object(Google_Service_MyBusiness_ListLocationsResponse)[88]
  protected 'collection_key' => string 'locations' (length=9)
  protected 'internal_gapi_mappings' => 
    array (size=0)
      empty
  protected 'locationsType' => string 'Google_Service_MyBusiness_Location' (length=34)
  protected 'locationsDataType' => string 'array' (length=5)
  public 'nextPageToken' => null
  public 'totalSize' => null
  protected 'modelData' => 
    array (size=0)
      empty
  protected 'processed' => 
    array (size=0)
      empty

怎么了?是我做错了什么,还是我有错误的证书。我如何检查/询问客户他是否给了我正确的访问权限。他可以在他的面板中检查帐户名吗?

您似乎在尝试使用服务帐户。根据doucmentation,您需要创建一个Oauth2客户端,并使用该客户端登录到一个可以访问my business帐户的帐户


根据文档,Google MyBusiness API似乎不支持服务帐户。

您似乎正在尝试使用服务帐户。根据doucmentation,您需要创建一个Oauth2客户端,并使用该客户端登录到一个可以访问my business帐户的帐户


根据文档,Google MyBusiness API似乎不支持服务帐户。

Json文件只是一个有权访问API的客户端。这并不意味着它可以访问任何数据。你需要一个用户来登录。您使用哪个帐户登录?这表明您的帐户没有访问任何my business帐户的权限。Json文件只是一个具有访问API权限的客户端。这并不意味着它可以访问任何数据。你需要一个用户来登录。您使用哪个帐户登录?这表明您的帐户没有访问任何my business帐户的权限。您在哪里找到GMB API不支持该服务帐户的信息?如果您查看,您会注意到它提到Oauth2。它没有提到服务帐户这是因为文档工作的方式是我们作为开发人员记录我们不支持的东西,而不是我们不支持的东西。要记录所有不受支持的内容将需要很长时间。@DalmTo,thx。那么为什么在我的客户端json中我有oauth2 ULR:
{“type”:“service\u account”、“project\u id”:“private\u key\u id”:“private\u key”:“private\u key”:“private key”,“client\u email”:googleapi@XX-ZZ-YY.iam.gserviceaccount.com,“客户id:“123456789”,“身份验证uri:”https://accounts.google.com/o/oauth2/auth“,“令牌uri”:"https://oauth2.googleapis.com/token,“身份验证提供程序\u x509\u证书\u url”:https://www.googleapis.com/oauth2/v1/certs,“客户端\u x509\u证书\u url”:https://www.googleapis.com/robot/v1/metadata/x509/googleapi%40XX-ZZ-YY.iam.gserviceaccount.com“}
这只是令牌端点。对于所有服务帐户客户端都是一样的,这取决于您使用什么API,而不是所有API都支持服务帐户身份验证。只要告诉他们让您成为Oauth2客户端,并给您一个具有访问权限的用户谢谢,我需要制作一些cron内容,无需手动、javascript登录,所以我需要service帐户:/GMB API不支持服务帐户的信息是从哪里找到的?如果您查看,您会注意到它提到了Oauth2。它没有提到服务帐户,这是因为文档工作的方式是我们作为开发人员记录我们不支持的内容,而不是我们不支持的内容。记录所有这些内容需要很长时间它不受支持。@DalmTo,thx。那么为什么在我客户端的json中我有oauth2 ULR:
{“type”:“服务帐户”、“项目id”:“私钥id”:“私钥”:“私钥”:“私钥”、“客户端电子邮件”:googleapi@XX-ZZ-YY.iam.gserviceaccount.com,“客户id:“123456789”,“身份验证uri:”https://accounts.google.com/o/oauth2/auth",   "令牌_uri“:”https://oauth2.googleapis.com/token,“身份验证提供程序\u x509\u证书\u url”:https://www.googleapis.com/oauth2/v1/certs,“客户端\u x509\u证书\u url”:https://www.googleapis.com/robot/v1/metadata/x509/googleapi%40XX-ZZ-YY.iam.gserviceaccount.com“}
这只是令牌端点。对于所有服务帐户客户端都是一样的,这取决于您使用什么API,而不是所有API都支持服务帐户身份验证。只要告诉他们让您成为Oauth2客户端,并给您一个具有访问权限的用户谢谢,我需要制作一些cron内容,无需手动、javascript登录,所以我需要servic电子帐户:/