我将使用 Facebook 3.6 SDK。我想要从 Graph 用户获取个人资料图片,上次我得到了图片,但现在它返回空的 Bitmap。
以下是我的代码:
当我使用直接链接时,它可以正常工作。
以下是我的代码:
private void onSessionStateChange(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
try {
URL imgUrl = new URL("http://graph.facebook.com/"
+ user.getId() + "/picture?type=large");
InputStream in = (InputStream) imgUrl.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(in);
//Bitmap bitmap = BitmapFactory.decodeStream(imgUrl // tried this also
//.openConnection().getInputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).executeAsync();
}
}
当我使用直接链接时,它可以正常工作。
imgUrl = new URL("https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.2365-6/851558_160351450817973_1678868765_n.png");
i refered this also Graph API Reference
&redirect=false
可以防止重定向,不是吗? - theapache64