Get Twitter's data from URL with Java - java

I'm trying to get the Twitter data from the Twitter page URL.
I.e. I have this URL http://twitter.com/eBay.
How can I to get followers number, etc... from every URL?
I'd like to use the Twitter API, but I've not an app to register. So it's not possible for me to authenticate, because I'm creating an University Thesis project.
Cheers.

I highly recommend using Twitter4J. It's a useful library for Java to parse all of this information. You can find it here.
As for not having an app to register, Twitter is pretty loose about obtaining credentials, so just create credentials on your personal twitter account and you should be good to go. You don't need a specific app to do it.
It's also important to know Twitter has rate limits on their API calls. You can find that information here.
Hope this helps!

Related

How to post with Google Plus API - Java

I'm trying to create a web service to use the Google Plus API. I'm writing it in java, however I can't figure out what files I need and how I would go about posting to Google plus groups using Java
If you have any insite please could you post relavent links and helpful tips to help me out.
EDIT 1:
I have been playing around with the GooglePlus API provived by Google and have written a project based on the sample code given from this page: https://developers.google.com/+/domains/posts/creating
The code runs fine until it gets to the GoogleTokenResponse tokenResponse = flow.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute(); line. Where it returns a null error. I am copying the link provided in the console and pasting in the code, however everytime it just returned a null error, is there a specific part of the returned code given that causes an issue?
Posting to Google+ is only supported for accounts in a Google Apps Domain (and even then, with restrictions).
If you are logging in using a GMail account - you don't have an Apps Domain account. If you're logging in using some other email address (ie - you have an email address, but you can't use Google account features such as GMail or Google Drive with it) then you don't have an Apps Domain account. If you are using a Domain account, your Domain admin may need to enable Google+ for your Domain before this works.
See https://developers.google.com/+/domains/getting-started for the differences between what you can do with the Domains API and the regular Plus API.
Note that neither API lets you post to a Google+ Community or post publicly. The Domains API does let you post to a user's circle, as long as the members of that circle are also part of the Domain. The Domain API also lets you post to everyone in the Domain. The normal Plus API does not allow posting at all.
There is a third API, knows as the Pages API, which allows Pages to publicly post on their stream. This API, however, is available to a limited number of partners such as Hootsuite. You can read more at https://developers.google.com/+/api/pages-signup, but there isn't much more available publicly.
Your web service should first authenticate against Google. This authentication can either be using a service account (if you want to post only through one account) or users's account (if you want to post via user's account) using oAuth mechanism.
For more details about how to authenticate, refer to How to authenticate our users in our website with Google Account
Have a look at https://developers.google.com/+/api/ for detailed information about how Google Plus APIs can be used.

Which is the safest/secure authorization option available for Google Analytics API?

We are developing a web service application to retrieve Google Analytics data for user's website using Google Analytics API.
The challenge we are facing is, at the authorization part. We are confused as to, which option to use for client authorization to access the analytics data.
As we are the third party application, it's obvious that the website owner wouldn't want to divulge any of his secret account information to us.
We are well aware of each option, it’s just that we need to know which is the safest / secure option for the website owner to provide us to access the analytics data.
Few options we know are:
Sharing client secrets file with us, or
Sharing service account details, or
If there is any other secure option which can be used here please
let me know.
Any guidance is appreciated.
Had posted the question in google groups site. Suggestion was to use OAuth 2.0 for Web Server applications.
Here is the link to the answer.

Google App for business + OpenId + GoogleAPIs in Java GAE

I'm finding a lot of problems trying to develop a google app to place in the market, with OpenID and accesing some google apis like G+ from the backserver on GAE
I have applications running using google apis to acces G+ data, with 3 legged oAuth (code flow) without problems and i understand the "magic" behind the scenes, but i'm getting lost with OpenID and google market. Do i need to do the 3legged oAuth after the user pass the OpenID google filter, and send the user to acept the G+ permission API to use that token to access google apis? If this is the case, what happen if the user access the application from his company gmail account, and when prompted to accept the g+ access, he change accounts? Is there any good reading that make things easier with google apps, openID and access google apis from GAE?
Why I can't specify the scope of G+ when sending my application to the market, in the app conf files?
In this scenario, what is the best way of getting the user g+ profile (picture, fullname, nickname? What i'm missing? google documentation is really good, when you find the correct one ,but a lot of links are dead and millions of examples with deprecated gdata apis are flooding the net...
Ok, after further reading and testing i came up with this points:
Google Marketplace just alow you to access this apis without extra "oAuth dances"
If you want to access more APIs than the listed above, you need the oAuth exchange to get specific token/s for the APIs you want to access.
In my case, i want to access G+ API before the openID from market, so after logging the user with openID, i need to redirect him to google api oAuth accept screen (just for the first time)
More things about the market that take me long time to catch:
- Billing API and license API are deprecated, this mean you are responsible for billing your users and keep them tracked to know if a given user has paid the application or when the license has expired
- You need to map /_ah/login_required becouse your application should be setted (when you create it) to only accept federated logins, wich will lead to a redirection to /_ah/login_required from where you need to do the openID stuff.
A lot of links in the documentation are broken and the examples are too old :(
It's actually a little simpler now with the new Google Apps Marketplace experience. If you follow the steps in the docs and make sure you ask for the same scopes in your App Engine code, the user should never be prompted.

Twitter4j and authenticating to Twitter

For the moment I'm just trying to get up a simple driver in Java to hook into the Twitter streaming API and gather some tweets. But the sample code provided on the twitter4j site doesn't work and it provides little direction as to how to properly authenticate to Twitter.
For now this is what I have (literally copied from the site):
http://pastebin.com/7udeFT9i
I did it programmatically this time, but obviously it doesn't authenticate with nothing but *'s. But I'm not sure what values to put into the ConfigurationBuilder. I've seen some that have hardcoded values and others that call a getter from a Twitter instance, but in general I'm just not sure what Twitter needs for me to be able to access the stream.
Use Scribe -
https://github.com/fernandezpablo85/scribe-java
You need to use OAuth to access twitter programmaticly. You should start with the Twitter OAuth docs:
https://dev.twitter.com/docs/auth/oauth/faq

Twitter OAuth question

I'm making a Twitter client in Java, and I've came to a problem I don't know how to solve it.
How the hell I store open auth for twitter? I mean it doesn't make very sense for a person to allow an application every time he wants to use the client. I've been look at the Twitter documentation, but I must say, it's really poor in terms of Java.
So do you guy have some idea to solve this?
Thanks in advance!
After your application successfully authenticates to Twitter, you will receive two strings: OAuthToken and OAuthTokenSecret. You store these tokens in a cookie, a user settings file, or wherever makes sense for your application.
Then, whenever you are making a call to the Twitter API, you retrieve these strings from the cookie or the user settings file, or wherever, and include them in the API call.
Or is there something about your question that I don't understand?
Yes, unless the user revokes the permission of your application.
Most of the time you need to store the twitter username and two tokens (public and secret). You get this tokens after you submit the password to the authorization twitter page.
So finally you would only need those three things to post and retrieve Twitter data.
Hope it helps.

Categories