【问题标题】:Using the userID to get a large profile picture Facebook使用用户 ID 获取大型个人资料图片 Facebook
【发布时间】:2015-08-21 02:28:00
【问题描述】:

当我使用图片 ID 时,我有点不确定如何从 facebook 当前检索大型个人资料图片。我正在将此 URL 加载到我的 imageview 中。

http://graph.facebook.com/1454465268197338/picture?type=large

但是当我输入它时它不会加载,虽然它可以工作。

https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xft1/v/t1.0-1/p200x200/11014854_1403982213245644_5725357301610737602_n.jpg?oh=9d95140ca58c8e13a950e14f63018ff4&oe=55F8A88F&gda=1442905098_49d2c7ec583d417722e02a10206c0fb6

我在上面输入的是第一个之后的重定向 URL。问题是我无法使用给定的用户 ID 生成它,因为我正在使用它。

@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);

    }

注意profile_pic_url。

所以最终,我怎样才能获得重定向的 url(因为我知道它有效)?

我怎样才能从用户那里获得一个大的 facebook 个人资料图片 url,因为请记住 facebook android id,因为我从中得到了什么:

                parameters.putString("fields", "id,name,link,picture,friends");

真的很小。

我尝试过使用

Java - How to find the redirected url of a url?

https://developers.facebook.com/docs/graph-api/reference/user/picture/

不幸的是,没有运气,

感谢您的帮助。

TYTY

【问题讨论】:

标签: java android facebook facebook-graph-api


【解决方案1】:

试试

parameters.putString("fields", "id,name,link,picture.type(large),friends");

– 这应该会为您提供个人资料图片的大版本。

(这利用Field Expansion 语法来更精确地指定您想要的数据。)

【讨论】:

    【解决方案2】:

    例如,您可以获得最小宽度为 1000 pic 的优质大照片,以及从纵横比给出的高度,使用下一个代码:

    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();
    
                    }
    

    在哪里

    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";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-08
      相关资源
      最近更新 更多