5

我已经构建了一个带有“使用 google 登录”功能的 windows phone 7 应用程序。Google 库与 windows phone 运行时不兼容,所以我选择 RestSharp。

该应用程序已成功接收到来自 Google 的验证码,下一步是将验证码交换为访问令牌和刷新令牌。在这里我遇到了一些问题。

var request = new RestRequest(this.TokenEndPoint, Method.POST);
request.AddParameter("code", code);
request.AddParameter("client_id", this.ClientId);
request.AddParameter("client_secret", this.Secret);
request.AddParameter("redirect_uri", "http://localhost");
request.AddParameter("grant_type", "authorization_code");
client.ExecuteAsync<???>(request, (response) =>
            {
                var passIn = response;
            }); // how to use this method?

我不确定如何使用该client.ExecuteAsync<T>方法(或任何其他方法会有所帮助)来获得 Google 的回复。是否有任何其他代码预先要求我使用这种方法?有谁能够帮助我?

4

2 回答 2

3

您需要绑定一个 UI 元素来显示响应。这似乎是您概述的问题的要点。

如果要在应用程序中显示响应,则应该将 UI 元素绑定到内部数据结构。

显示响应

// 在 xaml 中,例如 MainPage.xaml

<TextBox x:Name="myResponseTextBox">

// 在对应的 MainPage.xaml.cs

client.ExecuteAsync(request, (response) =>
{

   myResponseTextBox.text = response.Content; 

}); 

完成后,文本框将显示回调的结果

于 2012-03-06T18:42:03.350 回答
1

尝试:

client.ExecuteAsync(request, (response) =>
{
    var dataToBeParsed = response.Content;
});
于 2012-03-01T09:06:17.660 回答