I have used Twitter4j in past to read twitter public stream but have not used twitter hbc (which is twitter's official java library for streaming apis).
My use-case is to :
Listen to a twitter stream based on certain filter query.
My question is ?
what is your experience with these two above library and which is more suitable for usecase like mine
Short Answer
If you want to see the tweets tweeted about your search criteria right now in real time: go for hbc-twitter4j.
If you have questions like: get me up to date what happened in the recent past about your search criteria: go for Twitter4J.
Some details why
hbc is good at network reconnecting and network error handling in the background. This gives you a stable real time stream, especially with a bad network.
This is good if you watch what happens right now for hours.
I did not find a way to select the recent days like with Twitter4J.
Twitter4J: unlike hbc, it is easy to ask Twitter4J what happened in the recent past.
Twitter4J has some maintenance, hbc does not.
Both can store the result in Twitter4J classes like Status to give you easy access to the relevant Twitter fields.
Related
I am trying to retrieve tweets for a hashtag using Spring Social Twitter APIs.
When I pass the date in required format in "until" field, I am not able to retrieve the tweets.
I even tried directly invoking the REST API using https://dev.twitter.com/rest/tools/console (example https://api.twitter.com/1.1/search/tweets.json?
q=<>&lang=en&count=10&until=2016-12-10).
However without the "until" date API works fine both through Spring and REST Tool.
Appreciate if anyone could help me understand this behavior.
The Twitter Search API only searches against tweets in the last 7 days (as mentioned in the documentation). Thus, if your until field is before 7 days from the query submission, no results will return.
The only way to retrieve tweets posted longer than 7 days is to order a paid subscription to a Twitter service that has the ability to search against Twitter's historic data (i.e. Gnip, Nuvi, etc.). There are currently no free options that achieve this objective.
How to I send tweets to Twitter from java, looking for the simplest current solution please. As twitter always seems to be changing Im not even sure if this is possible and if there are any restrictions.
So I found that twitter4j was the most comprehensive and uptodate api, to access anything on twitter you need to use oauth and I didnt find the twitter4j documentation on this very clear.
However this excellant blog post http://www.javacodegeeks.com/2011/10/java-twitter-client-with-twitter4j.html clearly explains how to use oauth and update your twiiter status (send a tweet). Read through it carefully and it tells you exactly what you need to do and is really quite simple.
I am trying to use Java to search for a String on Google. I heard about a Google API but I wasn't able to find anything useful. It should look something like this:
I have a text file. Every Line is a String which should be googled. If the first search result is from a spezific site (for example: stackoverflow.com/**), The full link will be written in a new textfile. Any ideas how to realize that?
Thanks.
You can search on Google with its Custom Search API. There's a Java Client Library for CustomSearch API available to simplify the work. Warning : "Usage is free for all users, up to 100 queries per day."
Goolge offers a RESTful service to do custom queries programmatically called the Google Custom Search API.
It is not free though: you can submit up to 100 queries per day.
I want to query google programmatically in Java, to get texts for relation extraction purposes.
For example, I want to write in Java:
result_list=googleAgent.search("Berlin Germany");
In result_list, I can get a list of sentences which contain "Berlin" and "Germany". Then I can do NLP analysis and extract the relation.
Can I do it at all? And how if so?
Google prohibits programmatic searches directly through their website (that's why they have a search API). If you insist on trying to do this, Google will eventually pop up a captcha that your client will have to solve. So now you'll be trying to do NLP while you're doing OCR ;)
However, their search API isn't that great. You're limited to a certain number of queries per day (100) and information per result.
You can use Google's Custom Search API
Does google provide a Java server side api **(NOT java script).**I dont want the ajax api which works at clint side.
What i want is that the result returned for a keyword should return me search result in some specific data structure.Like List or set data structure.Then i want to manipulate the result according to my need in java code.
I had used such a java server site api for youtube.
They used to but is discontinued. Most likely because you can remove their ads ;-)
From Google's terms of service
You may not send automated queries of any sort to Google's system
without express permission in advance from Google.
So, no - use their AJAX API. The SAOP API is discoutinued, but I think you should be able to use it, unless it requires a key, in which case you are tied to the AJAX API
Technically, the statement quoted above doesn't mean you can't use some sort of server-side API - there are examples of that if you google around. It means you shouldn't do it, because sooner or later you will be blacklisted (banned), as violating the terms.
What you would be looking for now is the CustomSearch API:
They used to have a different API developers could use but it has been depreciated (Nov. 2009 I think) so this is a for cost service now. I am not aware how long it might have been a free service. The new API allows 100 free searches a day, but you have to be signed up for billing else anything above 100 searches will fail, here are the details:
http://code.google.com/apis/customsearch/v1/overview.html
And sorry yes, this would still be using Java Script but you could use this:
http://www.json.org/java/
There is at least a SOAP API that I'm aware of: Google SOAP Search API
I don't think Google wants 3rd parties to use their search engine for their own services/applications. You would get "we think you are a robot" error page as a result if Google thinks you are not a real person.
You can however try Google Custom Search