简体   繁体   中英

FQL Facebook SDK not working

I am trying to get my Facebook friends as JSON list, but using the guide below, did not work. It says that when clicking on Query, it should show something similar as this:

{
    data: [
        {
            pic_square: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/41666_1424840234_9458_q.jpg",
            uid: 1424840234,
            name: "Christine Abernathy"
        },
        {
            pic_square: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/211464_100002650977863_2642718_q.jpg",
            uid: 100002650977863,
            name: "James Forton"
        }
    ]
}

In the guide: "Tap ''Query'' and view the results in the console. Your log output should look similar to this:" But there is nothing in the console. I am running the app on my phone and when clicking on Query, Logcat shows:

Results: {Respone: ResponseCode: 200, graphObject: GraphObject{graph ObjectClass=GraphObject, state={"data":[]{}}, error: null, isFromCache:isfalse}

I am following this guide: https://developers.facebook.com/docs/android/graph/#fql-overview and have this code now:

// Query facebook friends
Button queryButton = (Button) findViewById(R.id.queryButton);

queryButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        String fqlQuery = "SELECT uid, name, pic_square FROM user WHERE uid IN " +
        "(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";
        Bundle params = new Bundle();
        params.putString("q", fqlQuery);
        Session session = Session.getActiveSession();
        Request request = new Request(session,
        "/fql",
        params,
        HttpMethod.GET,
        new Request.Callback(){
            public void onCompleted(Response response) {
                Log.i(TAG, "Result: " + response.toString());
            }
        });
        Request.executeBatchAsync(request);
    }
});

I have ran your code and I do get a response. A 200 response means there was no error on the FB server and you are simply receiving an empty result here. What Facebook SDK version are you using? Are you on Eclipse? You can run the query:

SELECT uid, name, pic_square FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)

on the Open Graph directly to debug it, but it is correct: https://developers.facebook.com/tools/explorer/ (Click on the FQL Query link next to Graph API, paste the query and click Submit).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM