How can auto post to google plus in PHP?

假如想象 提交于 2019-12-11 01:12:46

问题


I find article about Post on Google Plus on https://developers.google.com/+/api/latest/moments/insert

From that we find example shows how to create moment.

$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);

From Google APIs Client Library for PHP i'm not find api about Google_ItemScope, and Google_Moment is Google_PlusMomentsService.php. So can not try this example.

Anybody know about this? Or have solution can me try auto post on google plus using PHP?

Thanks


回答1:


i also found same problem, in new google + api they change class name try below code

$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);


来源:https://stackoverflow.com/questions/23236666/how-can-auto-post-to-google-plus-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!