我使用skybrud social允许用户通过Facebook登录我的网站,但遇到了问题。
由于某种原因,响应永远不会包含除用户名称和ID以外的任何内容......其他所有内容都为空。
var url = client.GetAuthorizationUrl(state, "public_profile", "email");
var service = FacebookService.CreateFromAccessToken(userAccessToken);
FacebookMeResponse user = service.Methods.Me();
以前有没有人经历过这个?可能是什么问题?
答案 0 :(得分:0)
Facebook有多个版本的Graph API。在最新版本(2.4)中,默认情况下返回的字段较少,而您必须告诉API返回所需的字段。您使用的API版本取决于您在Facebook上注册应用的时间。
根据您的代码,您似乎正在使用旧版本的Skybrud.Social。如果您更新到最新版本(0.9.4.1),则可以执行以下操作:
// Declare the options for the call to the API
FacebookGetUserOptions options = new FacebookGetUserOptions("me") {
Fields = "name,email,gender"
};
// Make the call to the API
FacebookUserResponse response = service.Users.GetUser(options);
希望这能回答你的问题;)