我如何获得喜欢Facebook用户帖子的朋友列表。我试过这段代码:
public class main {
public static void main(String[] args) throws IOException {
String accessToken = "EAACEdEoseZBhf0e4WXHuNaItvLeoAZD";
FacebookClient fbclient = new DefaultFacebookClient(accessToken);
Connection<Post> result = fbclient.fetchConnection("me/feed", Post.class);
int counter = 0;
for (List<Post> page : result) {
for (Post aPost : page) {
Date time = aPost.getCreatedTime();
Calendar c = Calendar.getInstance();
c.add(Calendar.YEAR, -10);
Date db = c.getTime();
{
if (!time.before(db)) {
System.out.println("created time " + time + "\r\n");
System.out.println("Id Poste: fb.com/" + aPost.getId() + "\r\n");
System.out.println(" L(userx) " + aPost.getLikes());
counter++;
} else {
System.out.println("date hors période" + "\r\n");
}
}
}
}
}
但是类似列表的结果是:
喜欢[data = [NamedFacebookType [id = 758248010897019 metadata = null name = Toka Ep Bouzidi type = null],NamedFacebookType [id = 836615436419028 metadata = null name = Basma Youssfi type = null],NamedFacebookType [id = 200283693703077 metadata = null name = Sahar Hmidet type = null],NamedFacebookType [id = 1589600437936215 metadata = null name = Fifi Daly Omm Omar type = null],NamedFacebookType [id = 2285678608326303 metadata = null name =RàNoutype = null],NamedFacebookType [id = 149760905397346 metadata = null name = Awatef Cherif type = null],NamedFacebookType [id = 197868283998495 metadata = null name = Samar Maamouri type = null],NamedFacebookType [id = 191663454652822 metadata = null name = Ben Ali Fatma Benali type = null],NamedFacebookType [id = 1594576777456573 metadata = null name = Rania Trigui type = null],NamedFacebookType [id = 10204633957434960 metadata = null name = Gasmi Ghassen type = null]] totalCount = 0]
===================================
我需要它来返回用户朋友的名字。
答案 0 :(得分:0)
System.out.println("Id Poste: fb.com/" + aPost.getLikes() + "\r\n");
Post.getLikes() 将返回类型为Post.like()的对象,该对象变为&#34;对象 - 乱码&#34;当试图打印时。对于Like-count使用Post.getLikeCount()[因为低代表不能来源,抱歉]
如需更详细的解答,请稍微说明您的问题。输出应该是什么样的?