我在Google Plus上找到关于Post的文章 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);
来自Google API的PHP客户端库我找不到关于Google_ItemScope的API,而Google_Moment是Google_PlusMomentsService.php。所以不能尝试这个例子。
有人知道吗?或者有解决方案可以尝试使用PHP在Google +上自动发布吗?
由于
答案 0 :(得分:2)
我也发现同样的问题,在新的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);