Reputation: 7219
I am trying to retrieve events that the user logged in has been invited to. While I was testing some stuff, I got stuck in this error while trying this FQL query:
public static List<GraphLocation> getEvents(Session session, Map<String, Object> queryParams){
limpar();
queryStringBuilder.append("SELECT eid, all_members_count, attending_count, declined_count, description, end_time, version, " +
"name, location, pic, privacy, start_time, ticket_uri, timezone, unsure_count, venue " +
"FROM event");
if(queryParams != null && !queryParams.isEmpty()){
whereClause.append(" WHERE ");
if(!queryParams.containsKey("dataInicio")){
whereClause.append("start_time = " + formatter.format((Date) queryParams.get("dataInicio")));
}
}
queryStringBuilder.append(whereClause.toString());
Bundle params = new Bundle();
params.putString("q", queryStringBuilder.toString());
Request request = new Request(session, "/fql", params, HttpMethod.GET,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
System.out.println(response.toString());
}
});
Request.executeBatchAsync(request);
return null;
}
private static void limpar(){
queryStringBuilder = new StringBuilder();
whereClause = new StringBuilder();
}
and here is the link to the image error on imageshack: http://img163.imageshack.us/img163/6848/erroew.png
If someone can tell me why is that issue happening I will be very happy, anyway, I will be even more happy if someone can also explain me how to grab events that a specific user is invited to.
Thanks a lot.
Upvotes: 2
Views: 545
Reputation: 406
The FQL query needs a WHERE statement, this is the cause of "Unexpected end of query" exception.
The Query you are looking for is this one
SELECT eid, all_members_count, attending_count, declined_count, description, end_time, version, name, location, pic, privacy, start_time, ticket_uri, timezone, unsure_count, venue
FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = XXXXXXX )
ORDER BY start_time asc
Replace XXXXXXX with the facebook user id.
In order to test FQL queries before integrating them into your code you can use Facebook Graph API Explorer, like here.
Note: don't forget to add "user_events" permission to your facebook app.
Upvotes: 1