在c#.net中使用Facebook登录时出错。我已经注册了正确的应用程序ID和facebookappsecret。 [英] Getting error during login with Facebook in c#.net. I have attechted right app ID and facebookappsecret.

查看:100
本文介绍了在c#.net中使用Facebook登录时出错。我已经注册了正确的应用程序ID和facebookappsecret。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{
错误:{

消息:无法加载网址:此网址的域未包含在应用的域中。为了能够加载此网址,将应用的所有域和子域添加到应用设置中的应用域名字段。,

type:OAuthException,

代码:191,

fbtrace_id:Gn / EdIdQhGh

}

}



i尝试了很多代码,但我无法获得登录/注册Facebook的用户详细信息



我尝试过的方法: < br $> b $ b

这个我的代码:



protected void登录(对象发件人,EventArgs e)
{
FaceBookConnect.Authorize(
user_photos,email ,Request.Url.AbsoluteUri.Split('? ')[0]);
}

protected void Page_Load(object sender,EventArgs e)
{
FaceBookConnect.API_Key =
APIkey ;
FaceBookConnect.API_Secret =
API_Secret ;
if(!IsPostBack)
{
if(Request.QueryString [
error ] == access_denied
{
ClientScript .RegisterStartupScript(this.GetType(),
alert alert(' 用户被拒绝访问。' < span class =code-string>,true);
返回;
}

字符串代码= Request.QueryString [代码 ];
if(!string.IsNullOrEmpty(code))
{
string data = FaceBookConnect.Fetch(code,
me );
FaceBookUser faceBookUser = new JavaScriptSerializer()。反序列化< FaceBookUser>(数据);
faceBookUser.PictureUrl = string.Format(
https: // graph.facebook.com / {0} / picture,faceBookUser.Id);
pnlFaceBookUser.Visible = true ;
lblId.Text = faceBookUser.Id;
lblUserName.Text = faceBookUser.UserName;
lblName.Text = faceBookUser.Name;
lblEmail.Text = faceBookUser.Email;
ProfileImage.ImageUrl = faceBookUser.PictureUrl;
btnLogin.Enabled = false ;
}
}
}
}
}

public class FaceBookUser
{
public string Id { get ; set ; }
public string 名称{ get ; set ; }
public string UserName { get ; set ; }
public string PictureUrl { get ; set ; }
public string 电子邮件{ get ; set ; }
}


请帮忙。

解决方案

阅读错误消息,它与您的代码无关,您需要配置您的Facebook应用程序以允许从该域访问

{ "error": {
"message": "Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.",
"type": "OAuthException",
"code": 191,
"fbtrace_id": "Gn/EdIdQhGh"
}
}

i have tried many code but i cant get user details who login/Register with facebook

What I have tried:

and this my code :


"
  protected void Login(object sender, EventArgs e)
         {
             FaceBookConnect.Authorize("user_photos,email", Request.Url.AbsoluteUri.Split('?')[0]);
         }

         protected void Page_Load(object sender, EventArgs e)
         {
             FaceBookConnect.API_Key = "APIkey";
             FaceBookConnect.API_Secret = "API_Secret";
             if (!IsPostBack)
             {
                 if (Request.QueryString["error"] == "access_denied")
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('User has denied access.')", true);
                     return;
                 }

                 string code = Request.QueryString["code"];
                 if (!string.IsNullOrEmpty(code))
                 {
                     string data = FaceBookConnect.Fetch(code, "me");
                     FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
                     faceBookUser.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", faceBookUser.Id);
                     pnlFaceBookUser.Visible = true;
                     lblId.Text = faceBookUser.Id;
                     lblUserName.Text = faceBookUser.UserName;
                     lblName.Text = faceBookUser.Name;
                     lblEmail.Text = faceBookUser.Email;
                     ProfileImage.ImageUrl = faceBookUser.PictureUrl;
                     btnLogin.Enabled = false;
                 }
             }
         }
     }
 }

 public class FaceBookUser
 {
     public string Id { get; set; }
     public string Name { get; set; }
     public string UserName { get; set; }
     public string PictureUrl { get; set; }
     public string Email { get; set; }
 }

 "
 Please help.

解决方案

Read the error message, it's nothing to do with your code, you need to configure your facebook app to allow access from that domain.


这篇关于在c#.net中使用Facebook登录时出错。我已经注册了正确的应用程序ID和facebookappsecret。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆