2

A few days ago I was asked if it's possible to show the posts of a specific google+ site on a website. I try to explain it more detail:

A concern has google+ account. The same concern has also a website. Now "Cool Concern" want to show all posts from google+ on the newssite of it's website.

I read the Google+ Web API and HTTP API, but nothing seems to satisfy my request.

I know this is an absolute newbie question. But I appreciate any hint:

  • is it in general possible?
  • which API I have to use?

Thanks a lot!

4

1 回答 1

4

对于用户和 Google+ 信息页,您可以通过 activities.list API 调用检索该帐户发布的所有公开帖子。由此,您可以在自己的网站上显示内容。

要进行活动列表 API 调用,您只需要您感兴趣的用户或 Google+ 信息页的 Google+ ID。如果您的用户正在登录您的网站,您可以使用特殊关键字'me'来引用当前经过身份验证的用户. 在 Python 中,这看起来像:

activities_resource = service.activities()
request = activities_resource.list(
  userId='me',
  collection='public',
  maxResults='2')

while request != None:
  activities_document = request.execute()
  if 'items' in activities_document:
    print 'got page with %d' % len( activities_document['items'] )
    for activity in activities_document['items']:
      print activity['id'], activity['object']['content']

  request = service.activities().list_next(request, activities_document)

您可以在https://developers.google.com/+/api/latest/activities/list查看其他语言的示例并了解更多信息。

但是,您需要缓存数据并定期刷新以确保没有过时的数据,并且从 Google+ 中删除的帖子不会保留在您的应用中。您可以在https://developers.google.com/+/policies查看完整的开发者政策。

于 2013-08-22T17:17:44.893 回答