Google+的API plus.me [英] Google+ API plus.me

查看:169
本文介绍了Google+的API plus.me的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:如何使用people.get与我的参数

The question: How to use people.get with the "me" parameter?

我知道如何使用 https://www.googleapis.com/plus/v1/people/ {ID},当获得JSON对象?关键= {键}

但什么参数应在即时通讯使用我为ID包括我?

but what parameters should I include when Im using "me" as id?

(我用 RESPONSE_TYPE = code 在AUTH)

编辑:(固定)

我使用ASP.NET,我发现这链接,但对访问令牌的JSON的POST请求将抛出一个错误。发送请求的作品,但,但是当我使用的GetResponse(),我得到错误(400)。而且还林不知道如果我使用URI是正确的: https://accounts.google.com/o/oauth2/token

I am using ASP.NET, and I found this link, but the POST request for the access token json throws an error. Sending the request works but, but when I use GetResponse(), I get error(400). And also Im not sure if the uri that I use is correct: https://accounts.google.com/o/oauth2/token

编辑2:

问题解决了。该请求是坏,因为我用 UTF32Encoding 而不是 UTF8Encoding 时,转换参数字符串写入流之前的byte [] 。随着 UTF8Encoding 做工不错。 :)

Problem solved. The request was bad because I used UTF32Encoding instead of UTF8Encoding when converting the parameter string to byte[] before writing to Stream. With UTF8Encoding works good. :)

code,我这个问题后写道:

Code that I wrote after this question:

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。

he called this with the parameters from here, and the returned string(json) contains my access_token.

推荐答案

我发送一个POST请求(信息的这里),以获得Oauth2 access_token和使用的:

I sent a POST request (info here) to get the Oauth2 access_token and used:

https://www.googleapis.com/plus/v1/people/me?key= {键}&放大器; access_token = {记号}

这篇关于Google+的API plus.me的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆