错误asp.net缺少client_id参数?

时间:2013-08-31 12:39:27

标签: asp.net facebook

获取 Facebook 用户详细信息时出现此错误。

{    
    "error": {
    "message": "Missing client_id parameter.",
    "type": "OAuthException",
    "code": 101    } 
 }

当用户点击 Facebook标签时,我会使用此解决方案。我试图更多地解决这个问题,但我不能。

public partial class DefaultPage : System.Web.UI.Page
{ 

    protected void Page_Load(object sender, EventArgs e)
    {
        FaceBookConnect.Authorize("user_photos,email",            
        Request.Url.AbsoluteUri.Split('?')[0]); 
        FaceBookConnect.API_Key = "111111111111111";
        FaceBookConnect.API_Secret = "xxxxxxxxxxxxxxxxxx";


            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; }
}

谢谢!

1 个答案:

答案 0 :(得分:1)

我怀疑这是因为你在实际调用authorize方法后设置了API Key和secret。尝试像这样交换它:

FaceBookConnect.API_Key = "111111111111111";
FaceBookConnect.API_Secret = "xxxxxxxxxxxxxxxxxx";

FaceBookConnect.Authorize("user_photos,email",            
Request.Url.AbsoluteUri.Split('?')[0]); 

如果这不能解决问题,那么您从哪里获取FaceBookConnect引用?