我有以下代码,提供以下输出。
我想知道是否有任何方式可以获得 TOTAL 数量的喜欢,而不仅仅是个人喜欢。
使用:jInstagram和Vaadin
谢谢!
代码:
MediaFeed mediaFeed = instagram.getRecentMediaFeed(userID); //Get recent images
List<MediaFeedData> mediafeed = mediaFeed.getData(); // Store info from mediaFeed into this list
for (MediaFeedData mediaData : mediafeed) { //For loop
int likes = mediaData.getLikes().getCount(); //Number of likes for each picture
System.out.println("Likes: " + likes); //Print likes
输出:
Likes: 1
Likes: 0
Likes: 0
答案 0 :(得分:2)
int totalLikes = 0;
for (MediaFeedData mediaData : mediafeed) { //For loop
totalLikes += mediaData.getLikes().getCount();
}
System.out.println("Likes: " + totalLikes); //Print likes