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.
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 am working on android studio with firebase. I created login and signup activities. The user can also update there profile picture and display name.
On retrieving the user profile, I am getting the displayname, email, provider, UID and profile picture.
In emulator image shows in the imageview but when running it on real
device image doesnot appear.
I have also added setPersistanceEnabled(true) but it doesnot solve. I have pasted my code by which user profile is created and retrieved.
private void updateProfile(String uName, Uri uri) {
UserProfileChangeRequest userProfileChangeRequest = new
UserProfileChangeRequest.Builder()
.setDisplayName(uName)
.setPhotoUri(uri)
.build();
user.updateProfile(userProfileChangeRequest);
mRef.child("Name").setValue(uName);
mRef.child(uri.getLastPathSegment()).setValue(uri.toString());
StorageReference profileStorage =
mStorage.child(uri.getLastPathSegment());
profileStorage.putFile(uri);
showMessage("Upload Successful");
Intent intent = new Intent(this,UserHome.class);
startActivity(intent);
}else{
showMessage("Upload Profile Picture");
}
}
////// for retrieving and displaying ///////
String namee = user.getDisplayName();
Uri uri = mAuth.getCurrentUser().getPhotoUrl();
Glide.with(UserHome.this).load(uri).into(imageView);
textView.setText(user.getDisplayName());
Log.v("data",user.getPhotoUrl().toString());
When you update the user profile after selecting an image from phone storage it uses your phone's image URI and updates the user account with it. And it displays it for the first before closing or signing out because it is still in the cache. But when you reopen or login to that account that cache is cleared and it does not display that image. So, to overcome this issue you have to upload that image to firebase storage first then get the link of the image and update the current user's photo with that link. It will be a universal link and will be working even after you have reopened your app or re-login to your account.
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/
I have an android app that I show the contacts details include the contact profile image.
This is how I get the contact image:
Uri photo = null;
String sPhoto = cursor
.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_ID));
if (sPhoto != null) {
photo = Uri.withAppendedPath(person,ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
myImageView.setImageURI(photo);
This code works just fine when the image is taken from the phone, but in my phone (like many others) I have a facebook profile, twitter profile etc, and in my default dialer I can see the facebook or twitter profile image beside the contact name, or the normal image (from the phone)
My code is given me only the image that exists in my phone, How do I get all images include facebook or twitter if such images exists?
Thank you
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.