如何在PHP中自动发布到Google Plus? [英] How can auto post to google plus in PHP?

查看:57
本文介绍了如何在PHP中自动发布到Google Plus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在上找到有关在Google Plus上发布信息的文章 https://developers.google.com/+/api/latest/moments/insert

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

在适用于PHP的Google API客户端库中,我找不到有关Google_ItemScope的api,而Google_Moment是Google_PlusMomentsService.php.所以不能尝试这个例子.

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.

有人知道吗?或有解决方案,我可以尝试使用PHP在Google加自动发布吗?

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

谢谢

推荐答案

我也发现了同样的问题,在新的google + api中,他们更改了类名,尝试使用以下代码

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

这篇关于如何在PHP中自动发布到Google Plus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆