facing problem in facebook connect api using asp.net
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Requires valid next URL.
Here is the code;
//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 开发者_如何学Gologin 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();
}
Does anyone knows how to get rid of this? Thanks in advance.
Instead of redirecting to the url, try using
base.login=true;
//Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0");
or
Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0&next=http://apps.facebook.com/yourapplication");
精彩评论