Getting activity id from Google+ URL?

Suppose I have an activity url (https://plus.google.com/u/0/113050383214450284645/posts/D6wBp4445Lb). I want to get an activity id to check Google+ API using APIs. What is the fastest way to do this, preferably without having to write any code?

+6
source share
1 answer

The easiest way is to simply use the API to retrieve the message identifiers.

Take the user id from the URL (113050383214450284645), then search for it or activity.list.

Sample requests for your URL:

Items in the activity feed will all have the identifiers you need.

"items": [ { "kind": "plus#activity", "etag": "\"vOizmBw459qRNcWY-IdfxxuCIbk/9EWWtEdBWwclTPqfqnRuN6-34Rg\"", "title": "Have you visited the World of Coke yet? What was your favorite part?", "published": "2012-11-05T14:54:01.010Z", "updated": "2012-11-05T14:54:01.010Z", "id": "z134ctopapf0vlfec23ahjiykpj2zf0ay04", "url": "https://plus.google.com/113050383214450284645/posts/D6wBp4445Lb", "actor": { "id": "113050383214450284645", "displayName": "Coca-Cola", "url": "https://plus.google.com/113050383214450284645", "image": { "url": "https://lh3.googleusercontent.com/-3o0qMaMvuwc/AAAAAAAAAAI/AAAAAAAAAng/X3xmoXJpksI/photo.jp g?sz=50" } }, 

In this example, the message identifier is z134ctopapf0vlfec23ahjiykpj2zf0ay04.

If you want to be more specific, you can make sure that you are retrieving the correct post by looking for a specific matching URL. The following code should give you the gist of how this is done in JavaScript:

 for (var activity in activities){ activity = activities[activity]; if (activity['url'] == postUrl){ targetActivity = activity; document.getElementById('result').value= 'ID is:\n' + activity.id; isFound = true; } } 

I created a small demo that shows how to do it here: Demo: URL for ID

+6
source

All Articles