Thursday, 16 August 2012

Retrieving Comments From Google+ Events

Had a question earlier about whether it was possible to retrieve comments from an event on Google+, and the answer is yes! As long as it's public, you can grab it via the REST public data APIs.

Taking as an example tonight's London Photowalk event, we need to first get the id of the activity. This can be done by grabbing the public posts by the Photowalk account:


GET https://www.googleapis.com/plus/v1/people/111455345092279041936/activities/public?alt=json&key={YOUR_API_KEY}
X-JavaScript-User-Agent:  Google APIs Explorer


The ID  "111455345092279041936" there is the ID of the Photowalk account. From that list we just need to find our event, and get the ID. You can generally see the Events posts by the provider field in the JSON of the object attached to the post.


"provider": 
    "Events"
},

We can then request the list of comments for that id using the plus.comments.list functionality.

GET https://www.googleapis.com/plus/v1/activities/z13xifyx5ybui5obk04cfdywyqyfunioy1w/comments?alt=json&key={YOUR_API_KEY}
X-JavaScript-User-Agent:  Google APIs Explorer

Take a look at the results over on the API explorer.