我一直试图通过facebook4j从我的朋友那里得到一些信息。但每次我尝试这样做时,我只收到空指针(除了id / name)。 这是代码:
` Stalker(String victimUsername,String yourUsername,boolean isFriend){
try {
friendList = facebook.getFriends(yourUsername);
if(isFriend){
int index = friendList.indexOf(facebook.getUser(victimUsername));
victimUser = friendList.get(index);
println(victimUser);
}
else
victimUser = facebook.getUser(victimUsername);
try {
birthdayVictimDate.setTime(df.parse(victimUser.getBirthday()));
}
catch(ParseException e) {
e.printStackTrace();
}
victimProfilePic = loadImage(facebook.getPictureURL(victimUsername).toString());
}
catch(FacebookException e) {
e.printStackTrace();
}
} `
如你所见:
FriendJSONImpl扩展了UserJSONImpl [id = 733939867,name = Tamires Ribeiro,firstName = null,middleName = null,lastName = null,gender = null,locale = null,languages = [],link = null,username = null,thirdPartyId = null,timezone = null,updatedTime = null,verified = null,bio = null,birthday = null,cover = null,education = [],email = null,hometown = null,interestedIn = [],location = null,political = null,favoriteAthletes = [],favoriteTeams = [],picture = null,quotes = null,relationshipStatus = null,religion = null,significantOther = null,videoUploadLimits = null,website = null,work = []]
如果用户不是我的朋友,我可以访问其中的一些信息,我得到了这个:
UserJSONImpl [id = 733939867,name = Tamires Ribeiro,firstName = Tamires,middleName = null,lastName = Ribeiro,gender = female,locale = pt_BR,languages = [],link = https://www.facebook.com/tamiresribeirodias,username = tamiresribeirodias ,thirdPartyId = null,timezone = null,updatedTime = Sat Oct 26 21:20:17 BRST 2013,Verified = null,bio = null,birthday = 05/13,cover = null,education = [EducationJSONImpl [year = null,type = College,school = IdNameEntityJSONImpl [name =里约热内卢联邦大学,id = 109442119074280],degree = null,concentration = [],classes = [],with = []]],email = null,hometown = null, interestIn = [],location = null,political = null,favoriteAthletes = [],favoriteTeams = [IdNameEntityJSONImpl [name = Vegetarianos Pensam Melhor,id = 240337606020973],IdNameEntityJSONImpl [name = Fluminense Football Club,id = 159225040801899]],picture = null,quotes = null,relationshipStatus =在关系中,religion = null,significantOther = IdNameEntityJSONImpl [name = Pedro Gabriel Lancelloti Pinto,id = 100000337547270],videoUploadLimits = null,website = null,工作= []]
正如你所看到的,我可以直接获得更多有关Facebook的信息,因为作为朋友,我应该得到相同或更多的信息。
有谁知道为什么会这样,以及如何解决? PS:在我的应用程序中,我设置权限“friends_birthday”并将其设置为我的user_token。