0

I use Twitter4J libraries to access Twitter through their Search API. I provide such a query to Twitter4j:

Query{query='#hungergames', lang='null', locale='null', maxId=-1, rpp=100, page=-1, since='null', sinceId=241378725860618240, geocode='null', until='null', resultType='recent', nextPageQuery='null'}

and

result = twitter.search(query); 

but I am not sure what URL is executes internally. Any insights into how I can find that out?

I know Twitter API documents how I should form the URL to query something here but I want to know what URL did Twitter4J execute.

chet
  • 607
  • 1
  • 6
  • 11

1 Answers1

1

The easiest way would probably be to sniff network traffic with a tool like Wireshark.

I used the following code to replicate your query:

public static void main(String[] args) throws TwitterException {
    Twitter twitter = new TwitterFactory().getInstance();
    Query query = new Query("#hungergames");
    query.rpp(100);
    query.setSinceId(241378725860618240L);
    query.setResultType(Query.RECENT);
    System.out.println(query);
    QueryResult result = twitter.search(query);
    for (Tweet tweet : result.getTweets()) {
        System.out.println(tweet.getFromUser() + ":" + tweet.getText());
    }
}

The line that prints the query gives me:

Query{query='#hungergames', lang='null', locale='null', maxId=-1, rpp=100, page=-1, since='null', sinceId=241378725860618240, geocode='null', until='null', resultType='recent'}

By sniffing the network traffic I found that the code is requesting the following URL:

http://search.twitter.com/search.json?q=%23hungergames&rpp=100&since_id=241378725860618240&result_type=recent&with_twitter_user_id=true&include_entities=true

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880