我很感激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);
感谢您的建议
答案 0 :(得分: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);
答案 1 :(得分: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;