【问题标题】:Google Domains API issue when post on user profile在用户个人资料上发布时出现 Google Domains API 问题
【发布时间】:2018-02-09 11:26:49
【问题描述】:

我在用户个人资料上发布问题(并非所有用户都出现错误)。

错误代码:400 错误消息:必须由 Google+ 信息页或代表 Google+ 信息页调用此方法。

$options = array( "headers" => array( 'content-type' => 'application/json;' ), "body" => json_encode($activity) );
$httpClient = $this->gplus->client->authorize(); 
$request = $httpClient->post("googleapis.com/plusPages/v2/people/$Id/activities";, $options);
$response = $request->getBody();
$googlePostResponse = $response->getContents();
$googlePostResponse = json_decode($googlePostResponse, TRUE); 

【问题讨论】:

  • 请附上您的代码
  • @DaImTo code $options = array( "headers" => array( 'content-type' => 'application/json;' ), "body" => json_encode($activity) ); $httpClient = $this->gplus->client->authorize(); $request = $httpClient->post("googleapis.com/plusPages/v2/people/$Id/activities", $options); $response = $request->getBody(); $googlePostResponse = $response->getContents(); $googlePostResponse = json_decode($googlePostResponse, TRUE);
  • 您可能想要编辑您的主题和标签。那是域 api 而不是 google puls 这与 Google+ 无关

标签: google-api google-workspace google-domain-api


【解决方案1】:

您当前使用的代码是 Google Domains api。该错误意味着您当前已通过身份验证的用户无权访问域帐户。确保授予用户访问权限,他们将能够发布到域 google+ 页面 authentication

注意:

Google+ API(社交媒体网站)和 Google Domains API (Gsuite) 之间存在差异

google+ api 是只读的,不允许以编程方式将帖子插入 Google+。

身份验证的工作原理

当您使用这些范围验证您的应用程序时

$this->client->addScope('googleapis.com/auth/plus.me'); 
$this->client->addScope('googleapis.com/auth/plus.stream.write'); 
$this->client->addScope('googleapis.com/auth/plus.stream.read'); 
$this->client->addScope('googleapis.com/auth/plus.pages.manage'); 
$this->client->addScope('googleapis.com/auth/plus.media.readwrite');

您是在询问用户我可以代表您做这些事情。但是,如果用户无权执行某项操作,您将无法执行此操作。

必须由 Google+ 信息页或代表 Google+ 信息页调用此方法。

与您进行身份验证的用户无权访问业务页面。因此,您的应用程序无法写入业务页面。如果您有 gsuite 帐户,则只能发布到域帐户。如果你没有,那么你不能发布到它。您不能只给他们您的业务页面的 ID,因为他们再次无权写入您的业务页面。

【讨论】:

  • 是的,但是,我在某些用户案例中遇到了这个问题。在其他用户的个人资料中,与代码配合得很好。它是错误的代码那么为什么在其他用户的个人资料帖子中工作?
  • 用户需要访问您的 gsuite 帐户才能代表域发帖。
  • 我会检查您发送的 access 和 access.type。
  • 此代码成功处理了大约 1400 个用户的个人资料发布。仅在大约 26 个用户中出现此错误。需要改代码吗?
  • 您可能需要授予这些用户访问权限。我会检查他们的权限。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-05
  • 1970-01-01
  • 2020-07-31
  • 1970-01-01
相关资源
最近更新 更多