Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 从Facebook获取数据时出错_Asp.net_Facebook - Fatal编程技术网

Asp.net 从Facebook获取数据时出错

Asp.net 从Facebook获取数据时出错,asp.net,facebook,Asp.net,Facebook,嗨,我在处理从FaceBook获取数据时遇到了这个错误: 错误 { “错误”:{ “消息”:“无效重定向\u uri:应用程序配置不允许给定URL。”, “类型”:“OAutheException”, “代码”:191 } } 代码 public partial class CS : System.Web.UI.Page{ protected void Login(object sender, EventArgs e) { FaceBookConnect.Auth

嗨,我在处理从FaceBook获取数据时遇到了这个错误:

错误

{ “错误”:{ “消息”:“无效重定向\u uri:应用程序配置不允许给定URL。”, “类型”:“OAutheException”, “代码”:191 } }

代码

public partial class CS : System.Web.UI.Page{
    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 = " 1111111111111111111";
        FaceBookConnect.API_Secret = "  xxxxxxxxxxxxxxxxx";
        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; }
}
公共部分类CS:System.Web.UI.Page{
受保护的无效登录(对象发送者、事件参数e)
{
FaceBookConnect.Authorize(“用户照片,电子邮件”,Request.Url.AbsoluteUri.Split(“?”)[0]);
}
受保护的无效页面加载(对象发送方、事件参数e)
{
FaceBookConnect.API_Key=“1111111111”;
FaceBookConnect.API_Secret=“XXXXXXXXXXXXXXXXXX”;
如果(!IsPostBack)
{
if(Request.QueryString[“error”]=“访问被拒绝”)
{
ClientScript.RegisterStartupScript(this.GetType(),“警报”,“警报('用户已拒绝访问')”,true);
返回;
}
字符串代码=Request.QueryString[“code”];
如果(!string.IsNullOrEmpty(代码))
{
string data=FaceBookConnect.Fetch(代码“me”);
FaceBookUser FaceBookUser=新的JavaScriptSerializer()。反序列化(数据);
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;
}
}
}
}
公共类FaceBookUser
{
公共字符串Id{get;set;}
公共字符串名称{get;set;}
公共字符串用户名{get;set;}
公共字符串PictureUrl{get;set;}
公共字符串电子邮件{get;set;}
}

检查您的应用程序设置,特别是本地测试的域partI,我必须上传到服务器进行测试,或者我可以做什么您可以使用本地应用程序进行测试。您在代码中使用了什么
redirect\u uri