0

我想使用 php 将我的 google plus 帐户链接到我的网站,以便显示来自我的 google plus 帐户的帖子(无需经过认证过程)。这是可行的,如果它是我应该使用的谷歌 api 吗?

问候

4

1 回答 1

1

您只能检索任何帐户的公开帖子。广泛的答案是,您可以作为未经身份验证的应用程序对活动列表 API 方法执行 API 调用,并且可以检索具有特定用户 ID(1xxxxxxxxxxx 而不是“我”)的用户的公共帖子。

您可以使用适用于 PHP 的 Google 客户端库来简化请求。假设您有一个完全连接Google_client的对象和一个实例化的Google_PlusService,您将能够调用:

$client = new Google_Client();
$client->setApplicationName('My Google+ PHP App');
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setDeveloperKey('insert_your_simple_api_key');
$plus = new Google_PlusService($client);
$posts = $plus->activities->listActivities('106189723444098348646', 'public', array());

上面的示例将检索拉里佩奇公开帖子的第一页。

于 2013-11-05T15:22:41.540 回答