Search code examples
twittertwitter-oauthtwitter4j

How to pass URL in twitter search API v1.1 in java using twitter4j


I am very new to Twitter processing in java. Have done it in python though. I have gone through many websites and started to analyze the concepts but am unable to understand the code involved in authenticating with twitter API v1.1.

Also I want to pass the URL link as a query for example I want tweets from @BCCI involving Sachin in the tweet. The search URL is https://twitter.com/search?q=%40BCCI%20Sachin&src=typd&lang=es

I have a query with keyword:

Query query = new Query("@BCCI"); query.setRpp(100);

Please assist me how I can approch this. Thank you.


Solution

  • Simply add multiple queries like this

    Query query = new Query("@BCCI Sachin");

    This means "@BCCI" and "Sachin". If you want either of them, you can use new Query("@BCCI OR Sachin")

    Many operators are available: https://dev.twitter.com/rest/public/search