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

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.

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

Related

Bluemix - Use Insights for Twitter API to query if a topic is trendy

I'm implementing a sorting algorithm and I want to query the Insights for Twitter API in order to find if a topic is trendy in comparison to another topic.
As far as I've investigated, there is a Count API Operation which will return the number of Tweets based on a given query. Therefore I could query how many Tweets have the particular "keyword" in their body and then compare it to other different keywords to establish an order.
Is there is a more direct query to know if a keyword is trendy?
Your approach using the /api/v1/messages/count endpoint looks like the right one when working with the Insights for Twitter API.
I guess you could also use the posted query parameter to build trending charts over time for your different keywords.

Java Library or API for extracting tweets of particular interest

I would like to know if there is a java library or API , that can extract tweets of my interest such as i want to know which tweets have reported about the strike in upcoming days in Islamabad city or bomb blast recently occured in my city . etc. I know there are other libraries out there but they only tell about whether the specific tweet is positive , negative or neutral. Thanks
Every library for integrating twitter tweets to your application is based on the twitter apis.
For your specific example, you can try Search API.
The process is really simple: just try from here your keywords to determine which keywords best suit your need and then use the actual API like this(returns tweets with keyword:Islamabad) to return the tweets you need in a JSON format.
NOTE:
Version 1.1 of the APIS uses an OAuth Authentication(I have not tried it yet so I can not provide more details :( ).
Now for Java libraries(frameworks) that simplify this process, the only one I know is Spring Social. But in case you are not familiar with Spring framework in general, the best thing is to just read the Json url generated by the api and unmarshall it to get your results.

How to crawl Twitter data

Ive searched through stack, but answers are dated. I was wondering if anyone knows what it is to crawl a topic like security. How do I do this by using Twitter? Do I just follow people who tweet about this topic, re-tweet and tweet new things, or is there an exact way of doing this? I then need to make statistical analysis on the data I gather.
You can use Puppeteer to crawl twitter data.
Checkout their github repository here.
This is a repository that crawls twitter data using Puppeteer .
How about using twitter search api (https://dev.twitter.com/docs/api/1.1/get/search/tweets)
You need to create an app first(or better say register an app) on dev.twitter.com and use search api to query for tweets that contain security (assuming I understood your crawling in the right way). Once you have your tweets you can do statistical analysis on the gathered data.
I use twitteR package on R to crawl twitter data (https://github.com/geoffjentry/twitteR) . It includes simple and useful functions to get twitter data.

What is Twitter API?

I would like to apologize first if the question is a total newbie question, but I really am a total newbie on this.
I'm a student and I recently have joined a project that involves studying (mining) tweets. The project head asked me to use the Twitter API to extract tweets. What exactly is Twitter API and how can I use it? What do I need to know to start using it?
Twitter allows you to interact with its data ie tweets & several attributes about tweets using Twitter APIs. You'd need to know a server side scripting language like php, python or ruby to make requests to twitter api and results would be in JSON format that can be easily read by your program.
A good starting point would be reading the official documentation at https://dev.twitter.com/ itself.
Throw you can use and show some functionality in your website

google search as an rss feed

Is there a way to have treat google serach results as an rss feed?
For example say I worked for stackoverflow and wanted to montior how if the results from the following search url: http://www.google.com/search?hl=en&q=stackoverflow changes from day today.
It would be cool if I could append &output=rss to the url and get back a feed like with google news. But that does not seem to be supported.
Anyone have ideas? (Note I am programing with Ruby and Rails, if that matters)
Thanks!
Jonathan
Google has the Google Alerts service, which notifies you whenever it finds new content matching a certain query. Besides sending to an email address (instantly, daily, weekly), it allows you to create an RSS feed out of it.
No, Google doesn't offer that feature.
If you need to parse/convert the result of a query on Google, you can use a (X)HTML parser such as Nokogiri.
Beware that automatic requests to Google may violate its TOS.

Resources