Android Facebook 可标记好友照片尺寸
Android Facebook taggable friend photo size
我可以从 facebook 查询可标记的朋友,但是照片 url return 太小了。
有没有办法得到更大的照片?
我试了所有我能想到的,但还是不行。
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);
}
};
如果知道解决方法请告诉我,不胜感激
您需要使用 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
me/taggable_friends?fields=name,picture.width(400).height(400)
请记住,这些是最小值,因此您可能会得到 "at least 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);
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);
这是解决方案,希望对其他人也有帮助。
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();
我可以从 facebook 查询可标记的朋友,但是照片 url return 太小了。 有没有办法得到更大的照片?
我试了所有我能想到的,但还是不行。
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);
}
};
如果知道解决方法请告诉我,不胜感激
您需要使用 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
me/taggable_friends?fields=name,picture.width(400).height(400)
请记住,这些是最小值,因此您可能会得到 "at least 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);
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);
这是解决方案,希望对其他人也有帮助。
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();