Package twitter4j.http

Examples of twitter4j.http.RequestToken


        String consumerKey = "Di1ZjpaZBqBTuCNBMmQ0g";
        String consumerSecret = "Qsa832hZ0z6Di2AY1umfhAgPowf2YtjCxQvooRzXTM";

        Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(consumerKey,consumerSecret);
        RequestToken requestToken = twitter.getOAuthRequestToken();
        AccessToken accessToken = null;

        p("go to this url: " + requestToken.getAuthorizationURL());
        p("then press enter");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String pin = br.readLine();
        if(pin.length() > 0){
            accessToken = twitter.getOAuthAccessToken(requestToken, pin);
View Full Code Here


                final Twitter twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer(consumerKey,consumerSecret);

                if(!context.getSettings().containsKey(TWITTER_TOKEN) || force) {
                    //u.p("no auth info already");
                    final RequestToken requestToken = twitter.getOAuthRequestToken();
                    final String url = requestToken.getAuthorizationURL();

                    final Textbox pin = new Textbox("");
                    pin.setPrefWidth(50);
                    pin.setWidth(50);
                    final Stage stage = Stage.createStage();
View Full Code Here

     * @param args message
     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new Twitter();
            RequestToken requestToken = twitter.getOAuthRequestToken();
            System.out.println("Got request token.");
            System.out.println("Request token: "+ requestToken.getToken());
            System.out.println("Request token secret: "+ requestToken.getTokenSecret());
            AccessToken accessToken = null;

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while (null == accessToken) {
                System.out.println("Open the following URL and grant access to your account:");
                System.out.println(requestToken.getAuthorizationURL());
                System.out.print("Hit enter when it's done.[Enter]:");
                br.readLine();
                try{
                    accessToken = requestToken.getAccessToken();
                } catch (TwitterException te) {
                    if(401 == te.getStatusCode()){
                        System.out.println("Unable to get the access token.");
                    }else{
                        te.printStackTrace();
View Full Code Here

        //Calling the new instance of Twitter
        Twitter twitter = newTwitter();


        try {
            RequestToken requestToken = twitter.getOAuthRequestToken();
            req.getSession().setAttribute(REQUEST_TOKEN_ATTRIBUTE, requestToken);
            req.setAttribute(AUTH_URL_ATTRIBUTE, requestToken.getAuthorizationURL());
            req.getRequestDispatcher(AUTH_FORM_VIEW).forward(req, resp);
        } catch (TwitterException e) {

            req.setAttribute("errorMsg", ERROR_STRING);
View Full Code Here

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Twitter twitter = newTwitter();

        HttpSession session = req.getSession();

        RequestToken requestToken = (RequestToken) session.getAttribute(REQUEST_TOKEN_ATTRIBUTE);


        try {

            session.removeAttribute(REQUEST_TOKEN_ATTRIBUTE);
View Full Code Here

        } else if (isTwitter) {
          try {
            LOGGER.fine("Initiating oAuth request for: "+op+", callback="+callbackUrl);
            Twitter twitter = new Twitter();
            twitter.setOAuthConsumer(provider.getConsumerKey(),provider.getConsumerSecret());
            RequestToken requestToken = twitter.getOAuthRequestToken();
            String token = requestToken.getToken();
            String tokenSecret = requestToken.getTokenSecret();
            session.setAttribute(ATTR_TOKEN,token);
            session.setAttribute(ATTR_TOKEN_SECRET,tokenSecret);
            url = requestToken.getAuthorizationURL();           
          } catch (TwitterException e) {
            err = "Unable to determine endpoint for: "+op;
            LOGGER.log(Level.SEVERE,err,e);
          }
View Full Code Here

    }

    try {
      twitter.setOAuthConsumer(key, secret);
      String callbackURL = buildCallBackURL(request, AuthenticationProvider.TWITTER);
      RequestToken token = twitter.getOAuthRequestToken(callbackURL);
      request.getSession().setAttribute("requestToken", token);
      String loginURL = token.getAuthenticationURL() + "&force_login=true";
      log.info("Redirecting to: " + loginURL);
      response.sendRedirect(loginURL);

    } catch (TwitterException e) {
      response.setContentType("text/html");
View Full Code Here

    Twitter twitter =    new TwitterFactory().getInstance();
    String key = AuthenticationProvider.getProp("twitter-consumer-key");
    String secret = AuthenticationProvider.getProp("twitter-consumer-secret");
   

    RequestToken token = (RequestToken) request.getSession().getAttribute("requestToken");
    String verifier = request.getParameter("oauth_verifier");
    twitter.setOAuthConsumer(key, secret);

    try {
      twitter.getOAuthAccessToken(token, verifier);
View Full Code Here

TOP

Related Classes of twitter4j.http.RequestToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.