Reputation:
I'm a little unsure how to retrieve a large profile picture from facebook current when I use the picture ID. I am loading this URL into my imageview.
http://graph.facebook.com/1454465268197338/picture?type=large
But it doesn't load, when I enter this though it works.
What I put above is the REDIRECTED URL after I put in the first. The problem is I cannot produce that with the userID I am given because I am using this.
@Override
public void onBindViewHolder(ContactViewHolder contactViewHolder, int i) {
Event ci = contactList.get(i);
contactViewHolder.vName.setText(ci.name);
TinyDB userinfo =new TinyDB(context);
String user_id = userinfo.getString("id");
profile_pic_url ="http://graph.facebook.com/"+user_id+"/picture?type=large";
Picasso.with(context)
.load(profile_pic_url)
.resize(225, 225)
.centerCrop()
.into(contactViewHolder.vProfilePic);
}
Pay attention to the profile_pic_url.
So ultimately, how can I get the redirected url (because I know that works)?
OR
how can I get a LARGE facebook profile picture url from the user because keep in mind the facebook android id because what I get from this:
parameters.putString("fields", "id,name,link,picture,friends");
IS REALLY SMALL.
I tried using
Java - How to find the redirected url of a url?
https://developers.facebook.com/docs/graph-api/reference/user/picture/
No luck unfortunately,
help is appreciated.
TYTY
Upvotes: 2
Views: 1025
Reputation: 1092
You can get good large photo with minimym width of 1000 pic, for example, and height given from aspect ratio, using next code:
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
String profileImg = "https://graph.facebook.com/" + loginResult.getAccessToken().getUserId() + "/picture?type=large&width=1000";
}
});
Bundle parameters = new Bundle();
parameters.putString(AuthConstants.FIELDS,
AuthConstants.ID + "," +
AuthConstants.BIRTHDAY + "," +
AuthConstants.FIRST_NAME + "," +
AuthConstants.LAST_NAME + "," +
AuthConstants.GENDER);
request.setParameters(parameters);
request.executeAsync();
}
Where
public static final String FIELDS = "fields";
public static final String ID = "id";
public static final String BIRTHDAY = "birthday";
public static final String FIRST_NAME = "first_name";
public static final String GENDER = "gender";
public static final String LAST_NAME = "last_name";
Upvotes: 0
Reputation: 96151
Try
parameters.putString("fields", "id,name,link,picture.type(large),friends");
– that should get you the large version of the profile picture.
(This makes use of Field Expansion syntax to specify which data you want more precisely.)
Upvotes: 5