Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中自动发布到google plus?_Php_Google Plus_Google Api Php Client - Fatal编程技术网

如何在PHP中自动发布到google plus?

如何在PHP中自动发布到google plus?,php,google-plus,google-api-php-client,Php,Google Plus,Google Api Php Client,我在Google Plus上找到了一篇关于Post的文章 从中我们发现,示例显示了如何创建力矩 $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->setTyp

我在Google Plus上找到了一篇关于Post的文章

从中我们发现,示例显示了如何创建力矩

$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_矩是Google_PlusMomentsService.PHP。所以不能尝试这个例子

有人知道这件事吗?或者有解决方案,我可以尝试使用PHP在google plus上自动发布吗


谢谢

我也发现了同样的问题,在新的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+API目前提供对公共数据的只读访问。所有API调用都需要OAuth 2.0令牌或API密钥。
该示例使用的是旧版本的客户端库。请尝试在Google/Service/Plus.php中查找Google\u服务\u Plus\u ItemScope,并使用相同的方式(片刻相同)。您能为我提供此类“Google\u服务\u Plus\u片刻”的链接吗?