Reputation: 6023
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
Upvotes: 0
Views: 2068
Reputation: 6023
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);
}
Upvotes: 2