Login with twitter is divided into two steps. First get the request token and the OAuth URL. Then clicking on the OAuth URL , twitter asks about your login credentials and redirects you to the callback URL. On that page you get the user access token and access secret. These token and secret act as your credentials for other twitter API calls.
So step one : Get the OAuth URL . click here
Step 2 : Callback URL. Here you get access token and access secret.
So step one : Get the OAuth URL . click here
Step 2 : Callback URL. Here you get access token and access secret.
<%@ page import="java.io.BufferedReader"%> <%@ page import="java.io.InputStreamReader"%> <%@ page import="java.net.URLEncoder"%> <%@ page import="oauth.signpost.OAuth"%> <%@ page import="oauth.signpost.OAuthConsumer"%> <%@ page import="oauth.signpost.OAuthProvider"%> <%@ page import="oauth.signpost.basic.DefaultOAuthProvider"%> <%@ page import="oauth.signpost.commonshttp.CommonsHttpOAuthConsumer"%> <%@ page import="org.apache.http.HttpResponse"%> <%@ page import="org.apache.http.client.HttpClient"%> <%@ page import="org.apache.http.client.methods.HttpPost"%> <%@ page import="org.apache.http.entity.StringEntity"%> <%@ page import="org.apache.http.impl.client.DefaultHttpClient"%> <%@ page import="org.apache.http.client.methods.HttpEntityEnclosingRequestBase"%> <% OAuthConsumer consumer=(OAuthConsumer)session.getAttribute("consumer"); OAuthProvider provider=(OAuthProvider)session.getAttribute("provider"); String pin=request.getParameter("oauth_varifier"); provider.retrieveAccessToken(consumer, pin); consumer.setTokenWithSecret
(consumer.getToken(),consumer.getTokenSecret()); session.setAttribute("token",consumer.getToken()); session.setAttribute("secret",consumer.getTokenSecret()); out.println(consumer.getToken()); out.println("<hr>"+consumer.getTokenSecret()); %>
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.