Java Reference
In-Depth Information
figure 10-20  
Note your API key and take note of the request token, authorize, and access token URLs. They'll
reappear in your code soon. You'll also need to modify your app permissions (click the link) and
allow for Read and Write access. Update your settings and go back to the Details tab. There, next to
the API key, click Manage API Keys and note your API Secret as well. Also note that the access level
has been set to Read and Write. As the Twitter page mentions, never give out your secret key to any-
one, as this will allow others to pose as your application. In real‐life applications, you'll want to store
this key in an encrypted form, but for these purposes, you can just use it in plain form in the code.
Next, create a TwitterTest class in a new com.twitter.api package to build a prototype working
with OAuth. The code should like the following:
package com.twitter.api;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.google.api.client.auth.oauth.OAuthAuthorizeTemporaryTokenUrl;
import com.google.api.client.auth.oauth.OAuthCredentialsResponse;
import com.google.api.client.auth.oauth.OAuthGetAccessToken;
import com.google.api.client.auth.oauth.OAuthGetTemporaryToken;
import com.google.api.client.auth.oauth.OAuthHmacSigner;
Search WWH ::




Custom Search