我正在尝试使用Facebook4j执行用户搜索,但用户对象的所有属性都设置为null(ID除外)。
到目前为止代码:
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.ResponseList;
import facebook4j.User;
import facebook4j.auth.AccessToken;
import facebook4j.conf.ConfigurationBuilder;
public class FacebookClient {
public static void main(String[] args) throws FacebookException {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthAppId("...")
.setOAuthAppSecret("...")
/*A user access token with the following scopes: public_profile, basic_info, email, user_birthday, user_religion_politics, user_relationships, user_relationship_details, user_hometown, user_location, user_likes, user_activities, user_interests, user_education_history, user_work_history, user_website, user_groups, user_events, user_photos, user_videos, user_friends, user_about_me, user_status, user_games_activity, user_tagged_places, user_actions.music, user_actions.video, user_actions.news, user_actions.books*/
.setOAuthAccessToken("");
FacebookFactory ff = new FacebookFactory(cb.build());
Facebook facebook = ff.getInstance();
ResponseList<User> results = facebook.searchUsers("John Smith");
for (User user : results) {
System.out.println(user.getFirstName() + " " + user.getLastName());
System.out.println(user.getBirthday());
System.out.println(user.getId());
System.out.println(user.getRelationshipStatus());
}
}
}
每个User对象的结果如下所示:
null null
null
111111111111111 //A different ID per object
null
是否需要调整权限配置以检索其他用户信息?
由于
答案 0 :(得分:0)
尝试执行out.println(facebook.toString())
以查看您是否拥有有效的实例。这可能是因为你是从静态主要尝试这个。