How can auto post to google plus in PHP?

2019-07-16 14:31发布

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条回答
乱世女痞
2楼-- · 2019-07-16 15:03

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);
查看更多
登录 后发表回答