新的Facebook SDK和OAuthException在Graphpath请求 [英] New Facebook SDK and OAuthException in Graphpath requests

查看:445
本文介绍了新的Facebook SDK和OAuthException在Graphpath请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了关于这个问题与旧版本的SDK答案的布赫,我似乎没有数字可以知道为什么,这是发生在我身上。

如果我用这个code,它完美的作品:

 查询字符串=选择UID,名称,pic_square,从用户is_app_user其中uid中(从朋友选择UID2那里UID1 =我());
保护无效getFacbookFirends(){
    捆绑PARAMS =新包();
    params.putString(Q,查询);
    最后请求REQ =新的请求(的getSession()/ FQL,参数,可以HttpMethod.GET,fbCallback);

    runOnUiThread(新的Runnable(){

        @覆盖
        公共无效的run(){
            Request.executeBatchAsync(REQ);
        }
    });
}
 

但这是非常丑陋的,所以我想用这个来代替:

 会话的会话= Session.getActiveSession();
如果(会话== NULL){
    会议=新的Session(getActivity());
}
如果(会话= NULL和放大器;!&安培; session.isOpened()){
    请求REQ = Request.newGraphPathRequest(会话,/我/的朋友?字段= ID,名称,安装,图片,
            新的回调(){
                @覆盖
                公共无效onCompleted(响应响应){
                            Log.w(FriendsListFragment.Facebook.onComplete,response.toString());
                }
            });
    Request.executeBatchAsync(REQ);
}
 

我的理解,这是完全相同的请求,并应运行只是以同样的方式,而是获得我想要的反应,我得到这个响应目标:

  {响应:
响应code:400,
graphObject:空,
错误:{FacebookServiceErrorException:
    HTT presponse code:400,
    facebookError code:2500,
    facebookErrorType:OAuthException,
    消息:一个活动接入令牌必须用于查询当前用户的信息。
    },
isFromCache:假的
}
 

如何,我可以使这项工作很好地有什么想法?

编辑:

我试图运行此code,仍然得到同样的结果:

 请求REQ =新的请求(会话,/我/的朋友?字段= ID,名称,安装,图片,空,HttpMethod.GET,
        新的回调(){

            @覆盖
            公共无效onCompleted(响应响应){
                        Log.w(FriendsListFragment.Facebook.onComplete,response.toString());
            }
        });
Request.executeBatchAsync(REQ);
 

解决方案
  

请求REQ =新的请求(会话,/我/的朋友?字段= ID,名称,安装,图片,空,HttpMethod.GET,.......

不要把整个路径图中的路径参数,之后的所有应该是你设置为null PARAMS参数。试试这个:

 捆绑PARAMS =新包();
params.putString(域,ID,名称,安装图);
请求REQ =新的请求(会话,我的/朋友,参数,可以HttpMethod.GET,.......
 

这将这样的伎俩。

I saw a buch of answers regarding this problem with the older versions of the SDK, and I can't seem figure out why this is happening to me.

if I use this code, it works perfectly:

String QUERY = "select uid, name, pic_square, is_app_user from user where uid in (select uid2 from friend where uid1 = me())";
protected void getFacbookFirends() {
    Bundle params = new Bundle();
    params.putString("q", QUERY);
    final Request req = new Request(getSession(), "/fql", params, HttpMethod.GET, fbCallback);

    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            Request.executeBatchAsync(req);
        }
    });
}

but this is very ugly, so I tried using this instead:

Session session = Session.getActiveSession();
if (session == null) {
    session = new Session(getActivity());
}
if (session != null && session.isOpened()) {
    Request req = Request.newGraphPathRequest(session, "/me/friends?fields=id,name,installed,picture",
            new Callback() {
                @Override
                public void onCompleted(Response response) {
                            Log.w("FriendsListFragment.Facebook.onComplete", response.toString());
                }
            });
    Request.executeBatchAsync(req);
}

to my understanding, this is the exact same request and should run just the same way, but instead of getting the response I wanted, I get this Response object:

{Response:  
responseCode: 400, 
graphObject: null, 
error: {FacebookServiceErrorException: 
    httpResponseCode: 400, 
    facebookErrorCode: 2500, 
    facebookErrorType: OAuthException, 
    message: An active access token must be used to query information about the current user.
    }, 
isFromCache:false
}

any thoughts about how I can make this work nicely?

EDIT:

I tried running this code and still got the same result:

Request req = new Request(session, "/me/friends?fields=id,name,installed,picture",null, HttpMethod.GET,
        new Callback() {

            @Override
            public void onCompleted(Response response) {
                        Log.w("FriendsListFragment.Facebook.onComplete", response.toString());
            }
        });
Request.executeBatchAsync(req);

解决方案

Request req = new Request(session, "/me/friends?fields=id,name,installed,picture",null, HttpMethod.GET, .......

Don't put the entire path in the graph path parameter, everything after the ? should be in the params parameter that you set to null. Try this instead:

Bundle params = new Bundle();
params.putString("fields", "id,name,installed,picture");
Request req = new Request(session, "me/friends", params, HttpMethod.GET, .......

That will do the trick.

这篇关于新的Facebook SDK和OAuthException在Graphpath请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆