简体   繁体   English

Twitter4j执行的API URL是什么? (搜索API)

[英]What is API URL executed by Twitter4j? (Search API)

I use Twitter4J libraries to access Twitter through their Search API. 我使用Twitter4J库通过其Search API访问Twitter。 I provide such a query to Twitter4j: 我向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. 但我不确定内部执行什么URL。 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. 我知道Twitter API记录了我应该如何形成URL来查询此处的内容,但是我想知道Twitter4J执行了什么URL。

The easiest way would probably be to sniff network traffic with a tool like Wireshark . 最简单的方法可能是使用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'} Query {query ='#hungergames',lang ='null',locale ='null',maxId = -1,rpp = 100,page = -1,since ='null',sinceId = 241378725860618240,geocode ='null' ,直到='null',resultType ='recent'}

By sniffing the network traffic I found that the code is requesting the following URL: 通过嗅探网络流量,我发现代码正在请求以下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 http://search.twitter.com/search.json?q=%23hungergames&rpp=100&since_id=241378725860618240&result_type=recent&with_twitter_user_id=true&include_entities=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM