-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
80 lines (70 loc) · 2.56 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package use_facebook4j;
import facebook4j.*;
import facebook4j.auth.AccessToken;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author SNEHAL
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FacebookException, IOException {
// TODO code application logic here
File file = new File("D:/projectnew.txt");
if(!file.exists())
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
Facebook fb = new FacebookFactory().getInstance();
fb.setOAuthAppId("", "");
//String tk = "CAACEdEose0cBAEoDNKKewS8vDdnSsq5xwzbSeXKFgdYrBKeMnlhwLwDRbySNwSBC5BFJAjJqgsCdFsDtvTL7mFPuI8W4MeEhT0Vw2Lpx4Eq4MUrWGhQuACxnZBDyZBXU5I2ty0LIPGaPWfHG47vAGephpSgzMNvZAlQDhKD6u3bjod07SIiZBVsiMUNLyyyfnpPTDqVQnwZDZD" ;
String tk = "950008355091625|z-s3PCV-f2nxKqW0BAgNNRW9G-Q";
AccessToken at = new AccessToken(tk);
fb.setOAuthAccessToken(at);
String[] s = {"ndtv","TimesofIndia","bbcindia","hindustantimes","thehindu","cnnibn","cnbc","ZeeNews","TIMESNOW","DDNewsLive","IndiaToday","ForbesIndia"};
//String[] s = {"ndtv"};
ResponseList<Post> feeds;
for(int i=0;i<s.length;i++)
{
feeds = fb.getFeed(s[i]);
System.out.println(s[i]+":"+feeds.size());
for(int j=0;j<feeds.size();j++)
{
Post p = feeds.get(j);
String msg = p.getMessage();
// System.out.println(msg);
bw.append(msg);
}
}
bw.close();
/* System.out.println("New without http");
FileReader fr = new FileReader("D:/projectnew.txt");
BufferedReader br = new BufferedReader(fr);
FileWriter fw1 = new FileWriter("D:/final.txt");
BufferedWriter bw1 = new BufferedWriter(fw);
while(br.readLine()!=null)
{
String t = br.readLine();
System.out.println(t);
if(t.contains("http"))
{
String[] temp = t.split("http");
t=temp[0];
}
System.out.println(t);
bw1.write(t);
}*/
}
}