【问题标题】:Why the facebook newMeRequest is not response?为什么 facebook newMeRequest 没有响应?
【发布时间】:2014-06-03 10:43:30
【问题描述】:

我使用以下代码获取我的 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函数,也就是说甚至没有记录错误信息。

谢谢

【问题讨论】:

    标签: android facebook facebook-graph-api facebook-sdk-3.1


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      这与我昨天在这里 (app crash when try get user photo by Facebook iOS Graph API with app-scoped user id) 回答的问题相同。

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

      【讨论】:

      • 我需要使用 .executeAsync() 并且我需要处理 facebook 个人资料图片 URL 的重定向
      猜你喜欢
      • 2020-10-16
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2020-03-16
      相关资源
      最近更新 更多