我正在获取Facebook个人资料信息以及个人资料图片。

public void getProfileInformationFacebook(AccessToken accToken) {
    GraphRequest request = GraphRequest.newMeRequest(
            accToken,
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(
                        JSONObject object,
                        GraphResponse response) {
                    Log.e("object", object.toString());
                    String fbId = null;
                    String fbEmail = null;
                    String fbName = null;
                    String fbUrl = null;

                    try {
                        fbId = object.getString("id");
                        fbEmail = object.getString("email");
                        fbName = object.getString("name");
                        JSONObject picture = object.getJSONObject("picture");
                        JSONObject pictureData = picture.getJSONObject("data");
                        fbUrl = pictureData.getString("url");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } finally {
                        regDetails("Facebook", fbId, fbName, fbEmail, fbUrl);
                    }
                }
            });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,location,birthday,picture");
    request.setParameters(parameters);
    request.executeAsync();
}


我收到的回复是这个

{"picture":{"data":{"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xfa1\/v\/t1.0-1\/c0.0.50.50\/p50x50\/32044_407244053957_1365573_n.jpg?oh=df9a5f89e6b19af9942cb948c952a026&oe=57559847&__gda__=1465809549_0402ad5c0dcf64f932ceabc982b02f5f","is_silhouette":false}},"id":"10153520390508958","email":"[email protected]","name":"Wishy Gupta"}


而且我从URL收到的个人资料图片太小。如何增加其宽度和高度?

最佳答案

你可以这样做,

fbProfilePicURL = "https://graph.facebook.com/" + fbID + "/picture?type=large&redirect=true";


只需将type属性更改为enum{small, normal, album, large, square}的任何人。

资料来源:Documentation

关于android - 获取具有首选宽度和高度的Facebook个人资料图片,Android?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35764388/

10-12 07:13