Twitter4j and authenticating to Twitter - java

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

Related

Query a gmail inbox through the API

I know this is a pretty noob question but I've been reading some manuals and documentations and can't figure something out.
I have an automation suite (in Java/Groovy) that in some cases needs to query an email inbox to check that a message with a given subject has been received and also probably delete all messages older than X. That's pretty much all I need to do and I've been looking into creating a gmail account and using the Google API Java client that's available here -> https://developers.google.com/api-client-library/java/apis/gmail/v1 but I can't figure our how to actually do it.
Right now what I have absolutely no clue how to do is the authentication. I can probably figure out how to interact with emails by going through the methods/code but I can't find any examples on how to authenticate so that the code can get access.
I tried looking for examples here and checking the code here. I know the answer is there but I still can't wrap my head around how to implement the code to sign in/authorize based on a username and password.
Thanks!.
This is the link you need. In this page it's explained authentication mechanism for Google API. They are using OAuth 2.0, which is probably the most used authentication method nowdays.
There is a standard flow that takes the client from credentials to an access token that can be used to perform authorised requests. This flow is described in the OAuth specification which is very useful to understand. Many APIs use it.
If you have specific questions, please let us know.

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.

Get Twitter's data from URL with 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!

What is Callback URL?

I am creating a new application in Twitter Twitter API
It is asking for CallBack Url what is main use of callback URL and its mandatory to use callback url as for me i am creating new app to get Access-Token so that i can use this to work with Twitter4j?
Twitter4j is used to integration Twitter API with Java.
I want following from this API
Login in my website through Twitter Like Stackverflow given login with OPENID
User Information
Number of follower
All Tweets of any account
Search on some Keyword basis
If i will not give Callback Url everything will work fine?
The purpose of the API is for you to make requests to Twitter.
Twitter needs to know where to send the results of your request.
Otherwise how will you know what happened? This is how you get the token to use it in your code.

Post tweet from client's account using Java

As per this SO answer and other google search results, it seems that twitter has stopped supporting username and password based authentication to post updates. However to my surprise, when I downloaded this app, it amazed me as it simply allows me to send tweets using my username and password only, requiring no consumer key and consumer secrets. So how is that possible?
All the tutorial I went through after googling suggested that I need to register my app and use the access token for posting. This also requires entering some PIN if I use it in my app. What I want is that my app must allow the client to enter only username and password to post tweets. So how should I do that in java?
I would even welcome a solution which utilizes the above app only to post tweets.(e.g. using Runtime.getRuntime())
Also refer this unanswered SO question. This is similar to what I want to do. Only that I want to do it using desktop application.

Categories