我一直在尝试通过 facebook4j 从我的朋友那里获取一些信息。但每次我尝试这样做时,我只收到空指针(id/name 除外)。这是代码:
` Stalker(字符串受害者用户名,字符串您的用户名,布尔值是朋友){
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,interestIn=[],location=null,political=null,最喜欢的运动员=[],最喜欢的团队=[],图片=null,引号=null,relationshipStatus=null,宗教=null,significantOther=null,videoUploadLimits=null,网站=null,工作=[]]
如果用户不是我的朋友,我可以访问其中的一些信息,我得到这个:
UserJSONImpl [id=733939867,name=Tamires Ribeiro,firstName=Tamires,middleName=null,lastName=Ribeiro,gender=female,locale=pt_BR,languages=[],link= https://www.facebook.com/tamiresribeirodias,用户名=tamiresribeirodias,thirdPartyId=null,时区=null,updatedTime=Sat Oct 26 21:20:17 BRST 2013,验证=null,bio=null,生日=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] ],图片=null,引号=null,relationshipStatus=在关系中,religion=null,significantOther=IdNameEntityJSONImpl [name=Pedro Gabriel Lancelloti Pinto,id=100000337547270],videoUploadLimits=null,website=null,work=[]]
如您所见,我可以直接通过 facebook 获得更多信息,这令人困惑,因为作为朋友,我应该获得相同或更多的信息。
有谁知道为什么会发生这种情况以及如何解决?PS:在我的应用程序中,我设置了权限“friends_birthday”,并将其设置在我的 user_token 中。