[英]facing problem in facebook connect api using asp.net
我正在使用Facebook connect API来获取我的好友列表。 它将我重定向到登录页面。
但是当我提供凭据时,会引发类似以下的错误;
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Requires valid next URL.
这是代码;
//my actual values are mentioned in the key
_fbService.ApplicationKey = "KEY";
_fbService.Secret = "Key";
_fbService.IsDesktopApplication = false;
string sessionKey = Session["Facebook_session_key"] as String;
string userId = Session["Facebook_userId"] as String;
// When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
string authToken = Request.QueryString["auth_token"];
if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.UserId = userId;
}
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
Session["Facebook_session_key"] = _fbService.SessionKey;
Session["Facebook_userId"] = _fbService.UserId;
Session["Facebook_session_expires"] = _fbService.SessionExpires;
}
else
{
Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0");
}
if (!IsPostBack)
{
// Use the FacebookService Component to populate Friends
//MyFriendList.Friends = _fbService.GetFriends();
MyFriendlist.Friends = _fbService.GetFriends();
}
有谁知道该如何摆脱? 提前致谢。
代替重定向到URL,请尝试使用
base.login = true;
//Response.Redirect(@“ http://www.Facebook.com/login.php?api_key= ” + _fbService.ApplicationKey + @“&v = 1.0”);
要么
Response.Redirect(@“ http://www.Facebook.com/login.php?api_key= ” + _fbService.ApplicationKey + @“&v = 1.0&next = http://apps.facebook.com/yourapplication ”);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.