TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raja A
NA
438
39.2k
Need to fetch User Email from Facebook api
Jan 21 2016 7:26 AM
Hi,
I have used the following code for getting facebook user's profile information for from api, But I cannot get email.. I am getting empty value, Can anyone tell me how to fix this,, Need urgent, Please help me...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPSnippets.FaceBookAPI;
using System.Web.Script.Serialization;
public partial class CSfacebook : System.Web.UI.Page
{
protected void Login(object sender, EventArgs e)
{
FaceBookConnect.Authorize("user_photos,email,user_location,user_birthday", Request.Url.AbsoluteUri.Split('?')[0]);
}
protected void Page_Load(object sender, EventArgs e)
{
FaceBookConnect.API_Key = "849760551813431";
FaceBookConnect.API_Secret = "5b8036220c5c4175865c6fb74c434425";
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;
lblBirthday.Text = faceBookUser.Birthday;
lblGender.Text = faceBookUser.Gender;
//lblLocation.Text = faceBookUser.Location.Name;
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; }
public string Birthday { get; set; }
public string Gender { get; set; }
public FaceBookEntity Location { get; set; }
}
public class FaceBookEntity
{
public string Id { get; set; }
public string Name { get; set; }
}
Reply
Answers (
2
)
Print barcode
How to "get" current settings of a windows service