In Facebook integration we can get email adddress by
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
User fbUser = new User();
Log.v(TAG, user.getProperty("email") + "");
}
});
When some one logged-in with facebook by using MOBILE NUMBER instead of EMAIL id.then,how to get that mobile number instead of email id.?
Facebook has retracted these features of the API due to privacy concerns.
Source: Here
Related
I am attempting to the number of friends from facebook authentication api in an android application needed to call facebook permission api. Below is a snippet I am using
fbLoginButton.setReadPermissions(Arrays.asList("public_profile, email, user_birthday, user_friends"));
the app fails with a json exception at this line
PUBLICPROFILE = object.getString("public_profile"); //error here
EDITTED - Here is a snippet of my attempt:
Name = object.getString("name");
Email = object.getString("email");
DOB = object.getString("birthday");
DOB = object.getString("birthday");
PUBLICPROFILE = object.getString("/me/friends");
Log.v("Email = ", " " + Email);
Log.v("PUBLIC PROFILE = ", " " + PUBLICPROFILE);
Please does anyone know how I can the number of friends from facebook on android login authentication
As per the facebook developer api /{user-id}/friends
1.the User's friends who have installed the app
2.the User's total number of friends (including those who have not installed the app making the query)
After getting facebook token you can use this implementation
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/{user-id}/friends",
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
// Insert your code here
}
});
request.executeAsync();
https://developers.facebook.com/docs/graph-api/reference/user/friends/
I'm trying to retrieve the authData field from a ParseUser. With Parse 1.9.1, I used to do it like so:
ParseUser user = ParseUser.getCurrentUser();
HashMap authDataMap = (HashMap)user.get("authData");
HashMap facebookMap = (HashMap)authDataMap.get("facebook");
String facebookId = (String)facebookMap.get("id");
And this worked fine.
Something changed though. I don't know if it's because I updated to Parse 1.9.2 or if something changed on the Parse server side, but authData is no longer accessible. The line user.get("authData") returns null. Even if I re-fetch the user.
Ultimately I want to retrieve the Facebook id from the ParseUser, preferably without reaching out to Facebook. Is this no longer possible?
If you are using ParseFacebookUtils to perform login Facebook user then after successfully login from in parse try to get GraphUser using following to fetch Facebook user data-
Request.newMeRequest(ParseFacebookUtils.getSession(),
new Request.GraphUserCallback() {
#Override
public void onCompleted(
final GraphUser fbUser,
Response response) {
try {
if (fbUser != null
&& parseUser != null
&& fbUser.getName()
.length() > 0) {
// Facebook user data
String fbId = fbUser.getId();
} else {
// Facebook user not logged in
}
} catch (Exception e) {
e.printStackTrace();
stopLoading();
}
}
}).executeAsync();
Have you taken a look at Facebook Users section in the Parse.com documentation. I think authData is for internal communication, not meant to be called (any more).
I'm developing my first Android App using Parse and Facebook, so I'm pretty new to it.
I'm trying to retrieve the User's Friend List with Request.newMyFriendsRequest() but it gives me an empty list when testing with real users.
As far as I know, with Graph API v2.0 this request only will return the set of the person's friends who also use the app.
For that purpose I created a fake Fb profile, I became friend with him in Facebook with my real profile, installed my app, registered with ParseUser and Linked with Facebook using ParseFacebookUtils.link with both profiles, but the Request returns an empty list of friends.
I've created several Test Users in Facebook's App dashboard, and simulated several friendships between them. I made the same process in my app (register with parseUser, link with ParseFacebookUtils.link) with two of them, and the list users.size() returns 2 friends as expected.
Why it doesn't work with my actual profile and the fake one (which is like any other real one)??
This is how I'm linking profiles:
List<String> permissions = new ArrayList<String>();
permissions.add("public_profile");
permissions.add("user_friends");
ParseFacebookUtils.link(currentUser, permissions, MainActivity.this, new SaveCallback() {
#Override
public void done(ParseException ex) {
if (ParseFacebookUtils.isLinked(currentUser)) {
Log.d(TAG, "Woohoo, user logged in with Facebook!");
Toast.makeText(getApplicationContext(), "Facebook succesfully linked", Toast.LENGTH_LONG).show();
}
if (ex != null) {
Log.d (TAG, ex.getLocalizedMessage() + "\n + Exception Code: " + ex.getCode());
}
});
And this how I Request friends:
Request.newMyFriendsRequest(ParseFacebookUtils.getSession(), new GraphUserListCallback() {
#Override
public void onCompleted(List<GraphUser> users, Response response) {
Log.d(TAG, "Request Completed!! " + response.toString() + "----" + users.size());
if (users != null) {
List<String> friendsList = new ArrayList<String>();
for (GraphUser user : users) {
friendsList.add(user.getId());
}
}
}
}).executeAsync();.
But I can't figure out how to get the friends list of a real user. With my profile it should return 1 friend who is also registered using the app being developed...
I got an empty array because of the following:
- This will only return any friends who have used (via Facebook Login) the app making the request.
Please note!
I'm trying to create a new ParseUser using a Google+ SignIn. While I'm able to retrieve the access token successfully from Google, I get a ParseException(InvalidSession).
I'll post a few snippets that are relevant.
This is how im getting the AccessToken from Google
final String SCOPES = "https://www.googleapis.com/auth/plus.login ";
token = GoogleAuthUtil.getToken(
MainActivity.this,
Plus.AccountApi.getAccountName(mGoogleApiClient),
"oauth2:" + SCOPES);
Making ParseUser
ParseUser.becomeInBackground(token, new LogInCallback()
{
public void done(ParseUser user, ParseException e)
{
Log.i(TAG, "makeParseUser"+"2");
if (user != null)
{
// The current user is now set to user.
/*
user.put("name", s1);
user.put("email",s6);
user.saveInBackground();
*/
}else
{
// The token could not be validated.
Log.i(TAG, "makeParseUser"+e.getLocalizedMessage());
}
}
});
A similar question has been asked here but there doesn't seem to be a proper solution to it.
Currently Parse doesn't support G+ login. Practically it can be done by using Parse cloud code.
ParseUser.becomeInBackground(); expects Parse User token, but not G+ one.
I searched for past two days and was not successful in finding the method to get the user id and access token from Facebook SDK 3.0 - Native Login .
i am following facebook native login - http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrumptious/authenticate/
and i get the access token using Session.getAccessToken , i get some access token but that is not valid . what is the actual procedure ? Am i doing wrongly ?
How to get the UserId in Native Login using Facebook SDK 3.0
user id:
final Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
// If the session is open, make an API call to get user data
// and define a new callback to handle the response
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (user != null) {
user_ID = user.getId();//user id
profileName = user.getName();//user's profile name
userNameView.setText(user.getName());
}
}
}
});
Request.executeBatchAsync(request);
}
user_ID & profileName are string.
for accessToken:
String token = session.getAccessToken();
EDITED: (13/1/2014)
for user email (i haven't check this code by running on device or emulator):
these are only my opinion or you can call it suggestion
setReadPermissions(Arrays.asList("email", ...other permission...));
//by analyzing the links bellow, i think you can set the permission in loginbutton as:
loginButton.setReadPermissions(Arrays.asList("email", ...other permission...));
user.asMap().get("email");
for more info see:
link1, link2, link3, link4,