简体   繁体   中英

Facebook fql query android

I want to get friends list aswell as some fields like profile_pic,username etc.., for that am using

SELECT name,relationship_status,current_location 
         FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

Its returning, <fql_query_response list="true"/>

and no friend list is coming.

Edit: `"https://api.facebook.com/method/fql.query?&access_token="+accesstoken+"&query=SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1="+id+")";`

and passing that to this method:

public String request(String fql)  throws FileNotFoundException, MalformedURLException, IOException {
             Bundle parameters = new Bundle();
             parameters.putString("format", "json");
             parameters.putString("query", fql);
             parameters.putString("access_token",facebookClient.getAccessToken());

             if (facebookClient.isSessionValid()) {
                 parameters.putString("access_token",facebookClient.getAccessToken());
             }
                     String url = (fql != null) ? "https://api.facebook.com/method/fql.query" : "https://api.facebook.com/restserver.php";
             return Util.openUrl(url, "GET", parameters);
             }

but its returning 400 bad request? but when i run this url in browser its working correctly

What am doing wrong? Can anyone please give me piece of code to execute this query?

Thanks

I got it atlaasst, the thing is we have to encode the fql query before executing query.

Use this:

 public String request(String fql)  throws FileNotFoundException, MalformedURLException, IOException {
             Bundle parameters = new Bundle();

             if (facebookClient.isSessionValid()) {
                 //parameters.putString("access_token",facebookClient.getAccessToken());
             }
                     String url = (fql != null) ? "https://api.facebook.com/method/fql.query?&access_token="+accesstoken+"&query="+URLEncoder.encode(fql) : "https://api.facebook.com/restserver.php";

                     System.out.println("url imple"+url);
                     return Util.openUrl(url, "GET", parameters);
             }

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