【问题标题】:How can auto post to google plus in PHP?如何在 PHP 中自动发布到 google plus?
【发布时间】:2014-04-23 06:37:42
【问题描述】:

我发现有关在 Google Plus 上发布的文章 https://developers.google.com/+/api/latest/moments/insert

从中我们可以找到示例显示如何创建时刻。

$moment_body = new Google_Moment();
$moment_body->setType("http://schemas.google.com/AddActivity");
$item_scope = new Google_ItemScope();
$item_scope->setId("target-id-1");
$item_scope->setType("http://schemas.google.com/AddActivity");
$item_scope->setName("The Google+ Platform");
$item_scope->setDescription("A page that describes just how awesome Google+ is!");
$item_scope->setImage("https://developers.google.com/+/plugins/snippet/examples/thing.png");
$moment_body->setTarget($item_scope);
$momentResult = $plus->moments->insert('me', 'vault', $moment_body);

从用于 PHP 的 Google API 客户端库中,我找不到关于 Google_ItemScope 的 api,而 Google_Moment 是 Google_PlusMomentsService.php。所以不能试试这个例子。

有人知道吗?或者有解决方案我可以尝试使用 PHP 在 Google 上自动发布吗?

谢谢

【问题讨论】:

标签: php google-plus google-api-php-client


【解决方案1】:

我也发现了同样的问题,在新的 google + api 他们更改类名尝试下面的代码

$plusservicemoment = new Google_Service_Plus_Moment();
$plusservicemoment->setType("http://schemas.google.com/AddActivity");
$plusService = new Google_Service_Plus($client);

$item_scope = new Google_Service_Plus_ItemScope();
$item_scope->setId('12345');
$item_scope->setType("http://schemas.google.com/AddActivity");
$item_scope->setName("yout site/api name");
$item_scope->setDescription("A page that describes just how html work!");
//$item_scope->setImage("full image path here");
$plusservicemoment->setTarget($item_scope);
$result = $plusService->moments->insert('me','vault',$plusservicemoment);

【讨论】:

  • 能否提供“Google_Service_Plus_Moment”这个课程的链接?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多