Package twitter4j

Examples of twitter4j.Twitter$Device


                throw new IllegalArgumentException("User or password were not set");
            }

            String message = configuration.getSimpleValue("message",null);

            Twitter twitter = createTwitterInstance();
            Status status = twitter.updateStatus(message);
            @SuppressWarnings({"UnnecessaryLocalVariable"})
            OperationResult result = new OperationResult("Posted " + status.getText());

            return result;
View Full Code Here


    /**
     * @param args
     */
    public static void main(String args[]) throws Exception {
        // The factory instance is re-useable and thread safe.
        Twitter twitter = new TwitterFactory().getInstance();

//insert the appropriate consumer key and consumer secret here

        twitter.setOAuthConsumer("TLGtvoeABqf2tEG4itTUaw",
                "nUJPxYR1qJmhX9SnWTBT0MzO7dIqUtNyVPfhg10wf0");
        RequestToken requestToken = twitter.getOAuthRequestToken();
        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("Enter the PIN(if aviailable) or just hit enter.[PIN]:");
            String pin = br.readLine();
            try {
                if (pin.length() > 0) {
                    accessToken = twitter.getOAuthAccessToken(requestToken, pin);
                } else {
                    accessToken = twitter.getOAuthAccessToken();
                }
            } catch (TwitterException te) {
                if (401 == te.getStatusCode()) {
                    System.out.println("Unable to get the access token.");
                } else {
                    te.printStackTrace();
                }
            }
        }
        //persist to the accessToken for future reference.
        System.out.println(twitter.verifyCredentials().getId());
        System.out.println("token : " + accessToken.getToken());
        System.out.println("tokenSecret : " + accessToken.getTokenSecret());
        //storeAccessToken(twitter.verifyCredentials().getId() , accessToken);
        Status status = twitter.updateStatus(args[0]);
        System.out.println("Successfully updated the status to [" + status.getText() + "].");
        System.exit(0);
    }
View Full Code Here

        throw new Exception("Nenhum valor para o parametro de usuario definido!");
      }
     
        response.setContentType("text/xml;charset=UTF-8");
        PrintWriter out = response.getWriter();       
        Twitter twitter = new TwitterFactory().getInstance();
        List<Status> statusList = getGeoStatusList(twitter, user);
        String template = "<entry>"
                + "<title>%s</title>"
                + "<link rel=\"alternate\" type=\"text/html\" href=\"%s\" />"
                + "<id>%s</id>"
View Full Code Here

     */
    currentSearch = popSearch();

    if (currentSearch != null) {
      logger.warning("-- Searching for " + currentSearch.getHashtag());
      Twitter twitter = TwitterFactory.getSingleton();
      Query query = new Query(currentSearch.getHashtag());
      query.setCount(100);
      //max o since?
      //that is
      //older than or newer than?
      if (currentSearch.isFirstScan())
        query.setMaxId(currentSearch.getMaxID());
      else
        query.setSinceId(currentSearch.getSinceID());
      QueryResult result;
      try {
        result = twitter.search(query);
        int size = result.getTweets().size();
        logger.warning("-- Going to iterate on "+ size + " tweets");
        if (size==0) {
          logger.warning("-- REACHED "+ size + " tweets");
          return;
View Full Code Here

        Query query = new Query(keywords);
        if (lastId != 0) {
            query.setSinceId(lastId);
        }

        Twitter twitter = te.getProperties().getTwitter();
        log.debug("Searching twitter with keywords: {}", keywords);
        QueryResult results = twitter.search(query);
        List<Tweet> list = results.getTweets();

        for (Tweet t : list) {
            long newId = t.getId();
            if (newId > lastId) {
View Full Code Here

    @Override
    protected Navigation execute(UserModel loginUserModel) throws Exception {

        // Titterオブジェクトの生成
        Twitter twitter = twitterFactory.getInstance();
        twitter.setOAuthConsumer(Constants.TWITTER_APP_API_KEY, Constants.TWITTER_APP_API_SECRET);

        // リクエストトークンの生成
        RequestToken twitterRequestToken = twitter.getOAuthRequestToken();

        // RequestTokenをセッションに保存しておきます。
        sessionScope("twitter", twitter);
        sessionScope("twitterRequestToken", twitterRequestToken);
View Full Code Here

    @Override
    protected Navigation execute(UserModel loginUserModel) throws Exception {

        // Titterオブジェクトの生成
        Twitter twitter = sessionScope("twitter");
        RequestToken twitterRequestToken = sessionScope("twitterRequestToken");
        String verifier = asString("oauth_verifier");

        AccessToken accessToken = null;

        try {
            // RequestTokenからAccessTokenを取得
            accessToken = twitter.getOAuthAccessToken(twitterRequestToken, verifier);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // Twitterアカウント情報と承認情報を保存
        if(accessToken != null){
            loginUserModel.setTwitterAccountName(twitter.getScreenName());
            loginUserModel.setTwitterAccessToken(accessToken.getToken());
            loginUserModel.setTwitterTokenSecret(accessToken.getTokenSecret());

            // ユーザーグループを変更
            if(loginUserModel.getGroup() < 10) {
View Full Code Here

        // 承認情報の生成
        ConfigurationBuilder cb = getConfigurationBuilder(userModel);

        // Titterオブジェクトの生成
        TwitterFactory twitterFactory = new TwitterFactory(cb.build());
        Twitter twitter = twitterFactory.getInstance();

        twitter.updateStatus(msg);
    }
View Full Code Here

        Query query = new Query(keywords);
        if (lastId != 0) {
            query.setSinceId(lastId);
        }

        Twitter twitter = twitterEndpoint.getTwitter();
        log.debug("Searching twitter with keywords: {}", keywords);
        QueryResult results = twitter.search(query);
        List<Tweet> list = results.getTweets();

        for (Tweet t : list) {
            long newId = t.getId();
            if (newId > lastId) {
View Full Code Here

            numberOfPages = te.getProperties().getNumberOfPages();
        }
       
        LOG.debug("Searching with {} pages.", numberOfPages);

        Twitter twitter = te.getProperties().getTwitter();
        QueryResult qr = twitter.search(query);
        List<Status> tweets = qr.getTweets();

        for (int i = 1; i < numberOfPages; i++) {
            if (!qr.hasNext()) {
                break;
            }

            qr = twitter.search(qr.nextQuery());
            tweets.addAll(qr.getTweets());
        }

        if (te.getProperties().isFilterOld()) {
            for (Status t : tweets) {
View Full Code Here

TOP

Related Classes of twitter4j.Twitter$Device

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.