Package twitter4j.http

Examples of twitter4j.http.AccessToken


      this.queue = (Queue)b.getBindable();

      TwitterFactory tf = new TwitterFactory();
      this.twitter = tf.getOAuthAuthorizedInstance(this.consumerKey,
                                                   this.consumerSecret,
                                                   new AccessToken(this.accessToken,
                                                                   this.accessTokenSecret));
      this.twitter.verifyCredentials();

      // TODO make filter-string configurable
      // this.filter = FilterImpl.createFilter(filterString);
View Full Code Here


        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);
        } else {
            accessToken = twitter.getOAuthAccessToken();
        }
        p("got the access token: " + accessToken);
        storeAccessToken(twitter.verifyCredentials().getId() , accessToken);

        AccessToken toke = new AccessToken(accessToken.getToken(), accessToken.getTokenSecret());
        twitter.setOAuthAccessToken(accessToken);
        Status status = twitter.updateStatus("quick test of twitter with oauth. hope this works! :)");
        p("changed the status to : " + status.getText());
    }
View Full Code Here

            csa.execute();
            if(!context.getSettings().containsKey(TWITTER_TOKEN)) return;

            twitter = new TwitterFactory().getInstance();
            twitter.setOAuthConsumer(consumerKey,consumerSecret);
            token = new AccessToken(context.getSettings().getProperty(TWITTER_TOKEN), context.getSettings().getProperty(TWITTER_TOKEN_SECRET));
            twitter.setOAuthAccessToken(token);
            //u.p("my id = " + twitter.getId());

            showConfigDialog();
            if(true) return;
View Full Code Here

                                        public void call(ActionEvent event) {
                                            stage.hide();
                                            try {
                                                String pinText = pin.getText();
                                                //u.p("using pin text " + pinText);
                                                AccessToken accessToken = twitter.getOAuthAccessToken(requestToken,pinText);
                                                context.getSettings().setProperty(TWITTER_TOKEN,accessToken.getToken());
                                                context.getSettings().setProperty(TWITTER_TOKEN_SECRET,accessToken.getTokenSecret());
                                            } catch (TwitterException e) {
                                                e.printStackTrace();
                                                StandardDialog.showError("Twitter authentication failed.\nPlease try again.");
                                            }
                                        }
View Full Code Here

      paging = new Paging();
      TwitterFactory tf = new TwitterFactory();
      this.twitter = tf.getOAuthAuthorizedInstance(this.consumerKey,
                                                   this.consumerSecret,
                                                   new AccessToken(this.accessToken,
                                                                   this.accessTokenSecret));
      this.twitter.verifyCredentials();
     
      // getting latest ID
      this.paging.setCount(TwitterConstants.FIRST_ATTEMPT_PAGE_SIZE);
View Full Code Here

     * @see <a href="http://apiwiki.twitter.com/OAuth-FAQ#Howlongdoesanaccesstokenlast">Twitter API Wiki - How long does an access token last?</a>
     * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2.  Obtaining User Authorization</a>
     * @since Twitter 2.0.8
     */
    public synchronized AccessToken getOAuthAccessToken(RequestToken requestToken, String pin) throws TwitterException {
        AccessToken accessToken = http.getOAuthAccessToken(requestToken, pin);
        setUserId(accessToken.getScreenName());
        return accessToken;
    }
View Full Code Here

     * @see <a href="http://apiwiki.twitter.com/OAuth-FAQ#Howlongdoesanaccesstokenlast">Twitter API Wiki - How long does an access token last?</a>
     * @see <a href="http://oauth.net/core/1.0/#auth_step2">OAuth Core 1.0 - 6.2.  Obtaining User Authorization</a>
     * @since Twitter 2.0.1
     */
    public synchronized AccessToken getOAuthAccessToken(String token, String tokenSecret) throws TwitterException {
        AccessToken accessToken = http.getOAuthAccessToken(token, tokenSecret);
        setUserId(accessToken.getScreenName());
        return accessToken;
    }
View Full Code Here

     * @param token token
     * @param tokenSecret token secret
     * @since Twitter 2.0.0
     */
    public void setOAuthAccessToken(String token, String tokenSecret) {
        setOAuthAccessToken(new AccessToken(token, tokenSecret));
    }
View Full Code Here

            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();
                    }
                }
            }
            System.out.println("Got access token.");
            System.out.println("Access token: "+ accessToken.getToken());
            System.out.println("Access token secret: "+ accessToken.getTokenSecret());

            Status status = twitter.updateStatus(args[0]);
            System.out.println("Successfully updated the status to [" + status.getText() + "].");
            System.exit(0);
        } catch (TwitterException te) {
View Full Code Here

public class TweetContentDelegate implements JavaDelegate {

  public void execute(DelegateExecution execution) throws Exception {     
    String content = (String) execution.getVariable("content");
     
    AccessToken accessToken = new AccessToken("220324559-8hWDVUXMSOaAnmtNNwBuNuhGJ6hOGwNdWHqhdOsU", "sGBZafB7saWYMwnPQGjjwU9Ggr0IJYkmPdyAFU5PI");
    Twitter twitter = new TwitterFactory().getOAuthAuthorizedInstance("HW62M0Rxtt39CbgdgP1og", "TJHNqolmPD6aHPtX8ec5Xp5zgIJcsMBTkwMpGCqdGuk", accessToken);
    twitter.updateStatus(content);
  }
View Full Code Here

TOP

Related Classes of twitter4j.http.AccessToken

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.