Created
November 30, 2013 15:44
-
-
Save danilovazb/7720604 to your computer and use it in GitHub Desktop.
java+geolocation+twitter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.util.List; | |
import twitter4j.Paging; | |
import twitter4j.ResponseList; | |
import twitter4j.Status; | |
import twitter4j.TwitterException; | |
import twitter4j.TwitterFactory; | |
public class pagination { | |
/** | |
* @param args | |
* @throws TwitterException | |
* @throws IOException | |
*/ | |
public static void main(String[] args) throws TwitterException, IOException { | |
FileWriter f = new FileWriter("RDSWEB.txt", true); | |
PrintWriter out = new PrintWriter(f); | |
for(int i = 1;i <= 500;i++){ | |
// // The factory instance is re-useable and thread safe. | |
twitter4j.Twitter twitter = TwitterFactory.getSingleton(); | |
// requesting page 2, number of elements per page is 40 | |
Paging paging = new Paging(i, 500); | |
ResponseList<Status> stats = twitter.getUserTimeline(829764080, paging); | |
for (Status status : stats) { | |
System.out.println(status.getGeoLocation()+" @"+status.getUser().getScreenName() + ":" + status.getText()); | |
out.println("\n"+status.getGeoLocation()+"|@"+status.getUser().getScreenName() + "|" + status.getText()+ "|" +status.getCreatedAt()); | |
} | |
} | |
// requesting page 3, since_id is (long)1000 | |
//stats = twitter.getUserTimeline(new Paging(3).sinceId(1000l)); | |
//for (Status status : stats) { | |
// System.out.println(status.getUser().getScreenName() + ":" + status.getText()); | |
//} | |
out.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment