From f4477c01e810b0afc06a27a037251e74b1a7f75e Mon Sep 17 00:00:00 2001 From: Jacklyn J Videira Date: Wed, 6 Feb 2019 14:03:36 -0500 Subject: [PATCH] Update Main.java --- MHealth_GroupFBScraper/src/Main.java | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/MHealth_GroupFBScraper/src/Main.java b/MHealth_GroupFBScraper/src/Main.java index 6271890..bd02761 100644 --- a/MHealth_GroupFBScraper/src/Main.java +++ b/MHealth_GroupFBScraper/src/Main.java @@ -48,14 +48,11 @@ public class Main { while(groupIt.hasNext()) { List page = groupIt.next(); for(Group currGroup : page) { - - //System.out.println("Do you want to get posts from "+currGroup.getName()+" ? Yes/NO"); // Eventually switch to GUI - //String response = input.nextLine(); - //if(response.equals("Yes")) { - // Removed above lines for testing (will need them in the future but not now since I'm only testing on one group) - if(currGroup.getId().equals("250530099176185")){ + // Will need to be changed in final version + System.out.println("Do you want to get posts from "+currGroup.getName()+" ? Yes/NO"); // Eventually switch to GUI + String response = input.nextLine(); + if(response.equals("Yes")) { Connection postFeed = fbClient.fetchConnection(currGroup.getId()+"/feed", Post.class, Parameter.with("fields","from,actions,message,likes,reactions,story,type,link,picture,created_time,comments")); - // Note - ask Jess if they want to be able to specify a start date / end date when pulling data writeCSVData(currGroup, postFeed, fbClient, userAccessTokens); } } @@ -66,20 +63,10 @@ public class Main { } public static void writeCSVData(Group currGroup, Connection postFeed, FacebookClient fbClient, String[] userApprovals) { - // TODO - Finish - // File Name should be of format: Health Chat_Data Type_Group Name_Date Pulled.csv - - /* - * - * Files needed: - * comments - headers: PostId, Id, UserId, UserName, CreatedTime, Message - * chat_feed - headers: Id, UserId, UserName, CreatedTime, Status Type, Message, Story, Link, Picture - * likes - headers: ObjectId, UserId, UserName - * reactions - headers: ObjectId, UserId, UserName, Type - * - */ + + Iterator> it = postFeed.iterator(); - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd.MM.yyyy hh.mm.ss"); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM.dd.yyyy hh.mm.ss"); LocalDateTime now = LocalDateTime.now(); DateFormat csvDateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); try {