2

我正在尝试检索已邀请登录用户的事件。当我测试一些东西时,我在尝试这个 FQL 查询时遇到了这个错误:

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();
}

这是imageshack上图像错误的链接:http: //img163.imageshack.us/img163/6848/erroew.png

如果有人能告诉我为什么会发生这个问题,我会很高兴,无论如何,如果有人也能解释我如何抓取特定用户被邀请参加的事件,我会更高兴。

非常感谢。

4

1 回答 1

1

FQL 查询需要 WHERE 语句,这是“Unexpected end of query”异常的原因。

您正在寻找的查询是这个

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

将 XXXXXXX 替换为 facebook 用户 ID。

为了在将 FQL 查询集成到您的代码之前对其进行测试,您可以使用 Facebook Graph API Explorer,就像这里一样。

注意:不要忘记将“user_events”权限添加到您的 Facebook 应用程序。

于 2013-05-28T22:35:03.163 回答