Google+ API plus.me

问题:如何使用带有“me”参数的people.get?

我知道如何在使用https://www.googleapis.com/plus/v1/people/{id}?key={key}时获取json对象

但是当我使用“我”作为id时,我应该包括哪些参数?

(我在auth中使用response_type=code

编辑:(固定)

我正在使用ASP.NET,我找到了这个链接 ,但访问令牌json的POST请求引发了错误。 发送请求有效,但是当我使用GetResponse() ,我得到错误(400)。 而且我也不确定我使用的uri是否正确: https://accounts.google.com/o/oauth2/tokenhttps://accounts.google.com/o/oauth2/token


编辑2:

问题解决了。 请求很糟糕,因为我在写入Stream之前将参数字符串转换为byte []时使用了UTF32Encoding而不是UTF8Encoding 。 使用UTF8Encoding效果很好。 🙂

我在这个问题之后写的代码:

 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Method = "POST"; UTF8Encoding utfenc = new UTF8Encoding(); byte[] bytes = utfenc.GetBytes(parameters); Stream os = null; try // send the post { webRequest.ContentLength = bytes.Length; // Count bytes to send os = webRequest.GetRequestStream(); os.Write(bytes, 0, bytes.Length); // Send it } // error handling... try // get the response { HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse == null) { return null; } StreamReader sr = new StreamReader(webResponse.GetResponseStream()); return sr.ReadToEnd().Trim(); } // error handling... 

他用这里的参数调用了这个,返回的字符串(json)包含了我的access_token。

我们为Google+ API开发了一个.NET客户端库。 该库使您可以轻松地使用任何.NET编程语言(如C#,VB.NET或ASP.NET)中的Google+ API

您可以在此处找到有关适用于Google+的.NET库的更多详细信息: http : //www.googleplustips.com/resources/3332-NET-Library-Google-APIs-released.aspx

当前版本支持所有Google+ API版本1,并与API Key配合使用。 调用任何Google API只需要一次方法调用。

只要您使用(OAuth)身份validation用户的访问令牌访问应用,就可以使用me ID。 引用G + API文档 :

如果使用userId值“me”,则此方法需要使用已授予OAuth范围https://www.googleapis.com/auth/plus.me的令牌进行身份validation。 阅读有关使用OAuth的更多信息。

示例:在使用PHP API客户端时,在发出例如之前

 $plus_api = new apiPlusService($client); // $client is the apiClient() object $plus_api->activities->listActivities('me', ...); 

您必须首先通过执行以下命令来设置经过身份validation的用户的访问令牌:

 $client->setAccessToken($access_token); 

使用该设置, me ID将被识别而没有问题。

我发送了一个POST请求( 此处为info)以获取Oauth2 access_token并使用:

https://www.googleapis.com/plus/v1/people/me?key={key}&access_token={token}

GetActivity和ListComments获取所有数据,或者它有一些方法(使用nextPageToken)来获取所有项目?

每个方法调用都会逐页返回结果集。 返回的对象有一个名为NextPageToken的属性,可以在下次调用时传递该属性以检索结果集的下一页。