0

对于 spring-social-facebook 库的实现,我将不胜感激。我正在尝试执行 FQL 查询,但 facebook 向我发送了空结果。如果我在 Facebook Graph API Explorer 中执行相同的查询,它就像一个魅力。我检查了所有权限。我的代码是这样的:

private static final String FQL_GET_FRIENDS = "SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())";

Facebook facebook = new FacebookTemplate(token);
List<Reference> references = facebook.userOperations().search(FQL_GET_FRIENDS);

谢谢你的建议

4

2 回答 2

1

行。这对我有用:

MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
        parameters.set("q", FQL_GET_FRIENDS);
Map<String, Object> resultSet = (Map<String, Object>) facebookTemplate
                .fetchObject("fql", Map.class, parameters);
于 2014-01-09T09:17:05.800 回答
0

我通过一个简单的 HTTP Get Request 使用具有足够权限的有效令牌对“facebookURL”做了同样的事情,你可以使用这个 ::

private static String STR_FACEBOOK_FQL_URL = "https://api.facebook.com/method/fql.query?query=";
private static String STR_FACEBOOK_RETURN_FORMAT = "&format=json";
private static String STR_FACEBOOK_ENCODE_FORMAT = "UTF-8";
private static String STR_FACEBOOK_ACCESS_TOKEN = "&access_token=";

private static final String FQL_GET_FRIENDS = "SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())";

String encodedQuery = URLEncoder.encode(FQL_GET_FRIENDS, STR_FACEBOOK_ENCODE_FORMAT);
String faceBookURL = STR_FACEBOOK_FQL_URL + encodedQuery + STR_FACEBOOK_RETURN_FORMAT
        + STR_FACEBOOK_ACCESS_TOKEN + token;
于 2014-01-07T12:54:46.383 回答