1

我使用以下代码获取我的 facebook 用户个人资料,问题是,当我触发 newMeRequest 时,它从未响应。

会话已经打开,我还在 manifest.xml 中添加了互联网权限,如何解决?感谢您的帮助

public class ProfileFragment extends Fragment {

private View rootView;
private ImageView profilePic;
private Context ctx;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    ctx = getActivity();

    rootView = inflater.inflate(R.layout.profile, container, false);
    profilePic = (ImageView) rootView.findViewById(R.id.profile_pic);

    Session session = Session.getActiveSession();

    if (session.isOpened()) {
        Log.d("test1","success 123");
        Request.newMeRequest(session, new MeReqCallback());
    } else {
        Log.d("test1","fail 123");
    }

    return rootView;
}

private class MeReqCallback implements GraphUserCallback {
    @Override
    public void onCompleted(GraphUser user, Response response) {
        Log.d("test1",response.getError().getErrorMessage());
        new ImageLoader(ctx).execute(profilePic,"https://graph.facebook.com/"+ user.getId() +"/picture");
    }       
}

登录后,进入成功123,但甚至没有进入onCompleted函数,这意味着甚至没有记录错误消息。

谢谢

4

2 回答 2

2

这与我昨天在这里回答的问题相同(尝试通过 Facebook iOS Graph API 获取用户照片时应用程序崩溃,应用程序范围的用户 ID )。

请求/me/picture会导致 http 304 重定向,并且显然ImageLoader()无法按照您当前使用的方式处理重定向。

于 2014-06-03T11:33:05.290 回答
2

您实际上并没有执行请求。在请求定义的末尾添加.executeAsync()

于 2014-06-03T20:54:33.193 回答