How to I send tweets to twitter from java - java

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.

Related

Twitter4j vs Twitter hbc

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.

How can I read content from web using Java?

I never had this tough reading content from online with other language, I am developing an android app, It's need to read some JSON data from online. But I googled it and gave it a try on my own, but nothing is working as I expected
I want to read that JSON from the web, is there any good way to do that?
Please do a search on volley or ok http for android on google. (Though ok http is obsolete but volley is surely a good alternative)
Use Retrofit + GSON libraries. They can satisfy wide range of expectations and have perfect samples.

Google page index - java

does any one has idea how to get google page index in Java?
I was googleing since last 2-3 days but helpless, can any one refer me API for that or give some suggestion for how to do that
Lots of thanks in advance
For example if we search for facebook in google, we get around 22,980,000,000 results. So I want to fetch this number using JAVA
make a corresponding HTTP request from Java to Google, then parse the replied HTML code. There is a div with the ID resultStats. This div contains the number of results.
Not sure what your real requirement is, what kind of index do you want? Google export fairly a bit amount of APIs via RESTful service, some of them are packaged with JavaScript lib like Google MAP API. There are also Java client library for OAUTH authentication
The custom search API information could be found at http://code.google.com/apis/customsearch/v1/overview.html. A comprehensive list of google APIs could be accessed at https://code.google.com/apis/console

How to search in google by using java code?

How to search in google by using java code?
I would have told you to use one of their API. Unfortunatly, there does not seems to exist one for search. As a consequence, you'll have to use HtmlUnit to emulate a browser and go see their results (obviously, you can go the harder way and do some HTTP queries by yourself. But who would do that ?).
Unfortunately the SOAP API has been deprecated. But you can use the AJAX API for non-JavaScript purposes as well, see for example:
http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php
Update Jul 3 2018: This link is now broken; some code from there can be found here: https://stackoverflow.com/a/1546475/55787, and I found a copy of the article here: https://blog.csdn.net/hgd250/article/details/5214702
Furthermore the orginial link to the AJAX API is now broken, too. It seems that this one is closest to the original meaning: https://developers.google.com/custom-search/json-api/v1/overview?csw=1
See also this StackOverflow question:
google java api for google search

google java api for google search

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

Categories

Resources