owe
owe

Reputation: 4930

How to show post of my google+ site on a website

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:

Thanks a lot!

Upvotes: 2

Views: 1370

Answers (1)

Joanna
Joanna

Reputation: 2176

For users and Google+ Pages, you can retrieve all of the public posts that account has made via the activities.list API call. From this, you can surface the content on your own site.

To make the activities.list API call, you need only the Google+ ID of the user or Google+ Page that you are interested in. If your users are logging in to your site, you can use the special keyword 'me' to refer to the current authenticated user. In Python, this looks like:

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)

You can see examples in additional languages, and learn more, at https://developers.google.com/+/api/latest/activities/list.

However, you will need to cache the data and refresh it regularly to ensure that there is no stale data, and that posts deleted from Google+ do not persist in your app. You can see the full developer policies at https://developers.google.com/+/policies.

Upvotes: 4

Related Questions