for getting user and his friend DOB we have to give user_birthday,friends_birthday in scope. for all scope and permission in facebook you can follow the link:
http://developers.facebook.com/docs/reference/api/permissions/
for getting DOB we can use FQL(facebook querry language) in callback.aspx.cs file:
calback.aspx.cs:
--------------------------------------------------
oAuthFacebook oAuth = new oAuthFacebook();
if (Request["code"] == null)
{
oAuth.AccessTokenGet(Request["code"]);
}
else
{
try
{
oAuth.AccessTokenGet(Request["code"]);
Api api = new Api(oAuth.Token);
User u = api.GetUser();
facebookId = api.UserID;
fullName = u.first_name + " " + u.last_name;
email = u.email;
photoPath = api.GetPictureURL(u.id);
var arr = api.Fql("SELECT birthday FROM user WHERE uid=" + facebookId);
NOTE: FQL returns JSON object which we can use to get user DOB like arr.JsonObjects[0].Properties["birthday"].ToString();
-------------------------------------------------
For getting friend's DOB
IList friends = (IList)api.GetFriends();
foreach (Facebook_Graph_Toolkit.FacebookObjects.NameIDPair pair in friends)
{
friendId = pair.id;
friendName = pair.name;
var arrFriend = api.Fql("SELECT birthday,email FROM user WHERE uid=" + friendId);
}
http://developers.facebook.com/docs/reference/api/permissions/
for getting DOB we can use FQL(facebook querry language) in callback.aspx.cs file:
calback.aspx.cs:
--------------------------------------------------
oAuthFacebook oAuth = new oAuthFacebook();
if (Request["code"] == null)
{
oAuth.AccessTokenGet(Request["code"]);
}
else
{
try
{
oAuth.AccessTokenGet(Request["code"]);
Api api = new Api(oAuth.Token);
User u = api.GetUser();
facebookId = api.UserID;
fullName = u.first_name + " " + u.last_name;
email = u.email;
photoPath = api.GetPictureURL(u.id);
var arr = api.Fql("SELECT birthday FROM user WHERE uid=" + facebookId);
NOTE: FQL returns JSON object which we can use to get user DOB like arr.JsonObjects[0].Properties["birthday"].ToString();
-------------------------------------------------
For getting friend's DOB
IList friends = (IList)api.GetFriends();
foreach (Facebook_Graph_Toolkit.FacebookObjects.NameIDPair pair in friends)
{
friendId = pair.id;
friendName = pair.name;
var arrFriend = api.Fql("SELECT birthday,email FROM user WHERE uid=" + friendId);
}
No comments:
Post a Comment