Android Facebook可标记的朋友照片大小

时间:2015-01-10 05:26:42

标签: android facebook facebook-graph-api

我可以从Facebook查询可标记的朋友,但照片网址返回太小。 有没有办法拍出更大的照片?

我尝试了所有我能想到但仍然无法工作的东西。

Request request = new Request(session,"/me/taggable_friends,",null,HttpMethod.GET);
Bundle params = new Bundle();
params.putInt("width", 100);
params.putInt("height", 100);
request.setParameters(params);

也试过这样的事情

Request request = new Request(session,"/me/taggable_friends?height=100,width=100",null,HttpMethod.GET);

以下是我处理会话的代码,我的应用程序没有登录按钮

private void onSessionStateChange(final Session session, SessionState state, Exception exception
{
    if(session.isClosed())
    {
        Session.openActiveSession(this, true, callback);
    }
}

@Override
public void onResume() {
    super.onResume();
    // For scenarios where the main activity is launched and user
    // session is not null, the session state change notification
    // may not be triggered. Trigger it if it's open/closed.
    Settings.addLoggingBehavior( LoggingBehavior.INCLUDE_ACCESS_TOKENS );
    Session session = Session.getActiveSession();
    if (session != null)
    {
        //if session is either closed or open we go to session state change
        //else we open it 
        if(session.isOpened() || session.isClosed()) 
            onSessionStateChange(session, session.getState(), null);
        else
            session.openForRead(new Session.OpenRequest(this).setPermissions(Arrays.asList("public_profile","user_friends")).setCallback(callback));
    }
}

这里是回调

private Session.StatusCallback callback = new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        onSessionStateChange(session, session.getState(), null);
    }
};

如果您知道解决方案,请告诉我,欣赏它。

4 个答案:

答案 0 :(得分:2)

me/taggable_friends?fields=name,picture.width(400).height(400)

请注意,这些是最小值,因此您可能会获得至少400x400"的图片。

另一种可能性:

me/taggable_friends?fields=name,picture.type(large)

我不是Android开发人员,但这是它的工作方式:

Request request = new Request(session,"me/taggable_friends", null, HttpMethod.GET);
Bundle bundle = new Bundle();
bundle.putString("fields", "name,picture.width(400).height(400)");
request.setParameters(bundle);

答案 1 :(得分:0)

您需要使用friends_taggable检索ID,然后使用ID:

/0101010101/picture?redirect=true&height=200&type=square&width=200

将0101010101替换为您想要的ID。

基本上你可以调用这个http地址并直接读取图片数据:

"http://graph.facebook.com/" + id
            + "/picture?redirect=true&height=200&type=square&width=200 

答案 2 :(得分:0)

Request request = new Request(session,"me/taggable_friends",null,HttpMethod.GET);
Bundle bundle = new Bundle();
bundle.putString("fields", "name,picture.type(large)");
request.setParameters(bundle);

这是解决方案,希望它也有助于其他人。

答案 3 :(得分:0)

Facebook已更新其图书馆,现在(4.1.0)的正确方法是:

    Bundle params = new Bundle();
    params.putString("limit","1000");
    params.putString("fields", "id,name,picture.width(256).height(256)");
    new GraphRequest(AccessToken.getCurrentAccessToken(),
            "/me/taggable_friends",
            params,
            HttpMethod.GET,
            new GraphRequest.Callback() {
                    @Override
                    public void onCompleted(GraphResponse graphResponse) {
                       if(graphResponse != null(){
                             // ... handle the result

                       }
                    }
            }).executeAsync();