我正在尝试让当前的 facebook 用户获得一个未托管在 .NET 页面中的 Silverlight 游戏,而只是一个 html 页面。silverlight 游戏将使用他们的 id 作为提交高分的凭证。
我不希望他们使用我的应用程序登录 Facebook。我希望他们在我的应用程序之外登录到 Facebook。然后我的应用程序使用 Graph API 的 .Get("me") 进行检查。但是,.Get("me") 总是返回 null。即使 facebookClient 有 App 访问令牌或 appid+secret。
我正在使用 C# facebook sdk 版本 5.4.1.0(用于 SL4 支持)。
这就是我尝试使用 appid+secret 的方式:
var app = new Facebook.FacebookClient(appId, appSecret);
app.GetCompleted += new EventHandler<Facebook.FacebookApiEventArgs>(app_GetCompleted);
app.GetAsync("me");
}
void app_GetCompleted(object sender, Facebook.FacebookApiEventArgs e)
{
//the value of me below is always null
var me = e.GetResultData() as IDictionary<string, object>;
string id = (string)me["id"];
}
根据其他网站,应用程序访问令牌应该足以获取当前 facebook 用户的 id:
- Facebook C# SDK 获取当前用户
- http://developers.facebook.com/docs/reference/api/user/
- Facebook C# sdk - FacebookApp.Get("me") 是访问 Facebook 还是仅访问 cookie?
- 获取当前用户的 UserId 的最佳方法是什么
- Facebook C# SDK 和访问令牌
我在做什么错/误解来获取当前的 facebook 用户 ID?
编辑:调试信息
Fiddler2 结果 404:
"message": "(#803) Some of the aliases you requested do not exist: clientaccesspolicy.xml",
"type": "OAuthException",
"code": 803
Fiddler2 结果 400:
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
FacebookApiEventArgs e.Error.Message:
Value cannot be null. Parameter name: stream
FacebookApiEventArgs e.Error.StackTrace:
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream)
at Facebook.FacebookClient.ProcessResponse(HttpHelper httpHelper, Stream responseStream, Type resultType, String& responseStr, Exception& exception, Boolean& cancelled)