i want to fetch user profile image and name by using user email address.
i am using facebook graph api
in my app user are able to post questions in your wall. and so he will get the responses by other users and we have only their email id so i have problem that how we access profile image and user id by using email address.
right now i am using facebook permission given below:
private static final String[] PERMISSIONS = new String[] {
"publish_stream", "read_stream", "offline_access" };
is there any other permission to access profile info by email address..
please figure out my problem...
For fetching user name and profile pic follow these steps-
Put this Permission-
public static final String[] FACEBOOK_PERMISSIONS = new String[]
{"publish_stream","email"};
Put this code in onComplete(Bundle mBundle) method -
JSONObject response = Util.parseJson(facebook.request("/me", mBundle, "GET"));
Get user name -
String userName = response.getString("username")
Now to get URL for profile pic make URL like this-
https://graph.facebook.com/userName/picture
For More details visit here.
The Facebook api doesn't allow you to find a profile given its email address. But if you have an access token that lets you read a user's wall, you should also be able to use it to obtain the profile image & display name for the author of each wall post.
You used to be able to search Facebook graph by email address to find a users name and image, but Facebook broke it and has taken months to fix it.
Related
I'm working on a game with Unity and FB in this game I wanted to show user FB profile pic.
I am doing this
FB.API("/me/picture?redirect=false", HttpMethod.GET, GetFBPic);
private void GetFBPic(IGraphResult result)
{
if (string.IsNullOrEmpty(result.Error) && !result.Cancelled)
{
IDictionary data = result.ResultDictionary["data"] as IDictionary;
string url = data["url"] as string;
}
}
for getting FB profile pic but the url here gives the FB gaming pic not FB profile pic i.e FB DP
how can I get FB profile pic (DP) url.
enter image description here
I'm searching this from long time but not getting anything, Anyone please help me in this
but the url here gives the FB gaming pic not FB profile pic i.e FB DP how can I get FB profile pic (DP) url.
It is up to the user, whether they want to enter your app using their standard Facebook user profile, or a special gaming profile.
https://developers.facebook.com/docs/games/acquire/login-for-gaming#requesting-user-s-profile-picture:
If user chooses the Facebook Profile option, both gaming_profile and gaming_user_picture permissions will be granted to application.
GET graph.fb.gg/v7.0/me/picture // return profile picture
If user chooses the gaming name and avatar option, only gaming_profile permission will be granted to application.
GET graph.fb.gg/v7.0/me/picture // return avatar
I'm working on an Android version of an app that uses Facebook for authorization and for retrieving user's friend list.
As of SDK v.2.0, it became pretty hard to get list of friends that hadn't installed your app, but I made it work and now I need to get links to friends profile pictures (avatars). But Facebook does not want to return normal IDs for friends that haven't installed the app. For example, if a friend installed an app then FB returns its ID as digits, something like this 651651616851, and if not then FB returns string of chars like "glkjrgbdjrbgjdrbhgjhLFKBfEFbFkjgnrg".
If I use digit-like ID to retrieve photo, it works, but if I try to use charlike ID, FB returns an 803 error.My question is how do I get normal IDs or how to get friends profile pictures?
This is the API call to get the pictures of friends, you can specify a (minimum) width and height:
/me/friends?fields=picture.width(400).height(400)
Please follow the link of facebook sdk about the Track Current Profile.
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
ProfileTracker profileTracker = new ProfileTracker() {
#Override
protected void onCurrentProfileChanged(
Profile oldProfile,
Profile currentProfile) {
// App code
Uri uri = currentProfile.getProfilePictureUri(200,200);
}
};
Now From Uri you can download the profile picture of user current profile.
In the new Google Sign-In API, I can get the profile photo using the following lines:
private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
GoogleSignInAccount account = result.getSignInAccount();
String profilePhoto = account.getPhotoUrl().toString();
}
}
But, there is no method in the account object to get the cover photo, so my question is : how to get the cover photo ?
Also, I want to get the birthdate and phone number
Thanks in advance :)
The GoogleSignInAccount class doesn't provide any methods for cover photo, birthdate or phone number. You can read more in the official documantation here.
For cover photo and birthdate you can make an authorized GET request here:
https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}
and you will get them in response.birthday and respone.cover.coverPhoto.url
Bear in mind that if you don't have a birthday date set, the request won't return any. And regarding the phone number, the I don't think the API offers that information.
As #Vlad said GoogleSignInAccount class doesn't provide any methods to retrieve the cover photo.
So, after a succeeded Google SignIn you could use the userId and API_KEY to make a GET request to:
https://people.googleapis.com/v1/people/{id}?personFields=coverPhotos&key={GoogleApiKey}
Replace {id} with userId and {GoogleApiKey} with API_KEY
I am working on Xamarin Android Application.I am using FacebooSdk for facebook-login.My problem is I am not getting email_Id and BirthDate of User.
This is how I give the permission:
LoginManager.Instance.LogInWithReadPermissions(this,new List<string>{"public_profile","user_friends","email","user_birthday"});
This is how I fetch the email Id and BirthDate:
emailId = e.mProfile.GetType ().GetProperty ("email").ToString ();
BirthDate = e.mProfile.GetType ().GetProperty ("user_birthday").ToString ();
If you are using xamarin's official facebook sdk. You can do this:
When creating loginButton, set permissions to read email and public profile
facebookLoginButton.SetReadPermissions("public_profile", "email");
Then simply use graphAPI to access name, ID, email and other public profile stuff.
I create app to Facebook with facebook-android-sdk:4.1.0
How to get all photo of logged in User?
I need to load user all photo
I use this code
I read this
I have to use Graph API
/* make the API call */
new Request(
session,
"/{photo-id}",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
please help
please explain
You can get everyone's Facebook profile picture using below.
You just call http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large. This URL redirects you to image URL.
extention onto my answer:
how do I get the entire album?
You need https://graph.facebook.com/[uid]/albums?access_token=[AUTH_TOKEN] to get JSON array of all the albums of a user.
You will get three important things from here id - album id, name - album name, and type - album type.
What permissions do I need?
The permission required is user_photos see here
What is the best way to get ALL profile pictures from a given user?
Profile Pictures are under "Profile Pictures" album. To get to profile album, you need to look into albums array (as mentioned previously), iterate through the JSON result-set, until you get an album with name = Profile Pictures and type = profile. Get id of this object. This is the profile pictures album.
Now you can access it similar to you access any other album. That is, https://graph.facebook.com/[ALBUM_ID]/photos?access_token=[AUTH_TOKEN] this will list all the profile pictures of the user ever uploaded.
Hope this helps.
refer: http://developers.facebook.com/docs/reference/api/