2
votes

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
Note: The Google+ API currently provides read-only access to public data. All API calls require either an OAuth 2.0 token or an API key. developers.google.com/+/api - waki
That sample is using an old version of the client library. Try looking for Google_Service_Plus_ItemScope in Google/Service/Plus.php, and use that the same way (same for Moment).github.com/google/google-api-php-client/blob/master/src/Google/… - Ian Barber

1 Answers

2
votes

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