要从Google+的网址获取活动ID? [英] Obtaining the activity id from a URL for Google+?
问题描述
假设我有一个活动的URL(https://plus.google.com/u/0/113050383214450284645/posts/D6wBp4445Lb).我想获取活动ID,以便可以使用API资源管理器测试Google+ API.什么是最快的方法(最好不必编写任何代码)?
Suppose I have the URL for an activity (https://plus.google.com/u/0/113050383214450284645/posts/D6wBp4445Lb). I want to obtain the activity ID so that I can test the Google+ API using the APIs explorer. What is the quickest way to do this, preferably without having to write any code?
推荐答案
最简单的方法是仅使用API资源管理器获取帖子ID.
The easiest way is to just use the API explorer to get post ids.
从网址(113050383214450284645)中获取用户ID,然后对其进行搜索或activity.list.
Grab the user ID from the url (113050383214450284645) then perform a search on it or activities.list.
查询您的网址的示例:
- Using the search API
- Using the activities list API
活动供稿中的所有项目都将具有您所需的ID.
The items in the activity feed all will have the IDs that 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"
}
},
在此示例中,帖子ID为z134ctopapf0vlfec23ahjiykpj2zf0ay04.
In this example, the post id is z134ctopapf0vlfec23ahjiykpj2zf0ay04.
如果您想更加准确,可以通过搜索特定的匹配URL来确保检索正确的帖子.以下代码应为您提供使用JavaScript进行操作的要点:
If you want to be even more accurate, you can ensure you are retrieving the right post by searching for a specific matched url. The following code should give you a 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;
}
}
我创建了一个小示例,演示了如何在这里完成操作: 演示:ID的URL
I have created a little demo that shows how this is done here: Demo: URL to ID
这篇关于要从Google+的网址获取活动ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!