1. You need to use the code from my website.
2. Then you need to modify the code as follows.
protected void Page_Load(object sender, EventArgs e)
{
FaceBookConnect.API_Key = "<FaceBook Key>";
FaceBookConnect.API_Secret = "<FaceBook 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;
byte[] bytes = new System.Net.WebClient().DownloadData(faceBookUser.PictureUrl);
//Save to database here
}
}
}
3. For saving byte array to database refer my article
Save and Retrieve images from database in ASP.Net