Example usage for twitter4j TwitterException toString

List of usage examples for twitter4j TwitterException toString

Introduction

In this page you can find the example usage for twitter4j TwitterException toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:br.unisal.twitter.bean.TwitterBean.java

public void postingToTwitter() {
    try {// w  w w .  ja va2s .  com
        TwitterFactory TwitterFactory = new TwitterFactory();
        Twitter twitter = TwitterFactory.getSingleton();

        String message = getTwitt();
        Status status = twitter.updateStatus(message);

        /*String s = "status.toString() = " + status.toString()
         + "status.getInReplyToScreenName() = " + status.getInReplyToScreenName()
         + "status.getSource() = " + status.getSource()
         + "status.getText() = " + status.getText()
         + "status.getContributors() = " + Arrays.toString(status.getContributors())
         + "status.getCreatedAt() = " + status.getCreatedAt()
         + "status.getCurrentUserRetweetId() = " + status.getCurrentUserRetweetId()
         + "status.getGeoLocation() = " + status.getGeoLocation()
         + "status.getId() = " + status.getId()
         + "status.getInReplyToStatusId() = " + status.getInReplyToStatusId()
         + "status.getInReplyToUserId() = " + status.getInReplyToUserId()
         + "status.getPlace() = " + status.getPlace()
         + "status.getRetweetCount() = " + status.getRetweetCount()
         + "status.getRetweetedStatus() = " + status.getRetweetedStatus()
         + "status.getUser() = " + status.getUser()
         + "status.getAccessLevel() = " + status.getAccessLevel()
         + "status.getHashtagEntities() = " + Arrays.toString(status.getHashtagEntities())
         + "status.getMediaEntities() = " + Arrays.toString(status.getMediaEntities())
         + "status.getURLEntities() = " + Arrays.toString(status.getURLEntities())
         + "status.getUserMentionEntities() = " + Arrays.toString(status.getUserMentionEntities());*/
        String s = "status.getId() = " + status.getId() + "\nstatus.getUser() = " + status.getUser().getName()
                + " - " + status.getUser().getScreenName() + "\nstatus.getGeoLocation() = "
                + status.getGeoLocation() + "\nstatus.getText() = " + status.getText();
        setTwittsResult(s);
        this.getUiMsg().setSubmittedValue("");
        this.getUiResultMsg().setSubmittedValue(getTwittsResult());
    } catch (TwitterException ex) {
        LOG.error("Erro no postingToTwitter() - " + ex.toString());
    }
}

From source file:com.example.leonid.twitterreader.Twitter.TwitterGetTweets.java

License:Apache License

@Override
protected List<CreateTweet> doInBackground(String... params) {
    mTweetsInfo = new ArrayList<>();
    List<String> texts = new ArrayList<>();
    List<String> titles = new ArrayList<>();
    List<String> images = new ArrayList<>();
    List<String> date = new ArrayList<>();
    if (!isCancelled()) {
        ConfigurationBuilder cb = new ConfigurationBuilder();
        cb.setDebugEnabled(true).setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET)
                .setOAuthAccessToken(ACCESS_KEY).setOAuthAccessTokenSecret(ACCESS_SECRET);
        TwitterFactory tf = new TwitterFactory(cb.build());
        Twitter twitter = tf.getInstance();
        //query search result
        Query query = new Query(params[0]);
        //how much tweets need to be displayed(max 200)
        query.count(200);/*from   w w  w. ja  v a 2s  . c  o  m*/
        try {
            mResult = twitter.search(query);
            for (twitter4j.Status status : mResult.getTweets()) {
                if (!isCancelled()) {
                    texts.add(status.getText());
                    titles.add(status.getUser().getName());
                    images.add(status.getUser().getBiggerProfileImageURL());
                    String cleanDate = status.getCreatedAt().toString();
                    date.add(cleanDate.substring(0, cleanDate.length() - 15) + " "
                            + cleanDate.substring(cleanDate.length() - 4));
                }
            }
        } catch (TwitterException e) {
            Log.e("exeption", e.toString());
        }
        //loop teuth results and create array list for list view
        for (int i = 0; i < texts.size(); i++) {
            mTweetsInfo.add(new CreateTweet(titles.get(i), images.get(i), texts.get(i), date.get(i)));
        }

    }
    return mTweetsInfo;
}

From source file:com.firewallid.crawling.TwitterApp.java

public User user(String userId) {
    try {/*from   w  ww.  ja v  a 2  s. c o  m*/
        return twitter.showUser(Long.parseLong(userId));
    } catch (TwitterException ex) {
        LOG.error(String.format("user. APP ID: %s. %s", apps[appIdx], ex.toString()));
        changeTwitter();
        return user(userId);
    }
}

From source file:com.firewallid.crawling.TwitterApp.java

public Status status(String tweetId) {
    try {/*from w  w w. ja  va 2  s . co m*/
        return twitter.showStatus(Long.parseLong(tweetId));
    } catch (TwitterException ex) {
        LOG.error(String.format("tweet. APP ID: %s. %s", apps[appIdx], ex.toString()));
        changeTwitter();
        return status(tweetId);
    }
}

From source file:com.firewallid.crawling.TwitterApp.java

public QueryResult search(Query query) {
    try {/*from   w w  w  .  ja  va2s. c  o m*/
        return twitter.search(query);
    } catch (TwitterException ex) {
        LOG.error(String.format("search. APP ID: %s. %s", apps[appIdx], ex.toString()));
        changeTwitter();
        return search(query);
    }
}

From source file:com.tweetmyhome.TweetMyHome.java

private void sendDm(long idDestiny, String text) {
    try {//  ww  w.  j av  a2 s . c o  m
        long superUserId = db.getSuperAdminId();
        DirectMessage dm = tw.sendDirectMessage(idDestiny, text);
        db.add(new SimpleDirectMessage(this, dm.getId(), superUserId, null, text,
                Calendar.getInstance().getTimeInMillis()));
        tweetCount.incementCount();
    } catch (TwitterException ex) {
        error(ex.toString(), ex);
    }
}

From source file:com.tweetmyhome.TweetMyHome.java

private void sendT(String text) {
    try {/*w ww.  ja  v a 2  s .c o m*/
        long superUserId = db.getSuperAdminId();
        Status updateStatus = tw.updateStatus(text);
        SimpleMention sm = new SimpleMention(this, updateStatus.getId(), superUserId, null, text,
                Calendar.getInstance().getTimeInMillis());
        db.add(sm);
        tweetCount.incementCount();
    } catch (TwitterException ex) {
        error(ex.toString(), ex);
    }
}

From source file:com.tweetmyhome.TweetMyHome.java

/**
 * IO DEVICE (HARDWARE) MESSAGE//  w  ww  .ja  v a2 s  . c  o m
 * @param device
 */
@Override
public void recivedIOEvent(DeviceSensor device) {
    TweetMyHomeDevices.Sensor sensorFired = null;
    for (TweetMyHomeDevices.Sensor s : tmh_device_xml.getSensor()) {
        if (s.getAttachedPin().intValue() == device.getPin()) { // se busca por pin
            sensorFired = s;
            break; // ya que no pueden existir otros sensores
        }
    }
    if (sensorFired != null) {
        debug("Evend catched [" + sensorFired.getName() + "] in pin [" + sensorFired.getAttachedPin()
                + "] activated [" + device.isActivated() + "]");
        int sensorIdByPin = db.getSensorIdByPin(sensorFired.getAttachedPin().longValue());
        if (sensorIdByPin != TweetMyHomeDatabase.NOT_EXIST) {
            HistorySensor historySensor = new HistorySensor(sensorIdByPin,
                    Calendar.getInstance().getTimeInMillis(), device.isActivated() ? 1 : 0,
                    db.getSuperAdminId());
            db.add(historySensor);
            debug(historySensor.toString());
        } else {
            warn("Sensor pin [" + sensorFired.getAttachedPin().longValue()
                    + "] does't founded in DB. event not register");
        }
        if (sec.isEnabled()) {
            sect.estimulate();
            info("Sensor fire [" + sensorFired.getName() + "," + sensorFired.getLocation()
                    + "], thread level : " + sect.getRiskByEstimulation().name());
            if (sect.isEstimulationOverThreshold()) { // WARNING
                warn("Estimulation over threshold !!");
                if (com.isActivated()) {
                    String warnPublicMessage = "Hogar en riesgo [" + sect.getRiskByEstimulation().name() + "] "
                            + TENDENCE + " " + tweetCount.getHexHashTagCount();
                    info("Comunity mode is enabled , Tweeting public message");
                    try {
                        tw.updateStatus(warnPublicMessage);
                        db.add(new SimpleMention(this, sensorIdByPin, sensorIdByPin, TENDENCE, TENDENCE,
                                Calendar.getInstance().getTimeInMillis()));
                    } catch (TwitterException ex) {
                        error(ex.toString(), ex);
                    }
                }
                info("Sending private message to all activated users");
                db.getAllUsers().forEach(u -> {
                    String warnPrivateMessage = "Hogar en riesgo [" + sect.getRiskByEstimulation().name() + "]"
                            + " " + tweetCount.getHexHashTagCount();
                    ;
                    if (u.isActivado() && (u.getRol() != UserRol.super_admin)) {
                        try {
                            tw.sendDirectMessage(u.getIdTwitterUser(), warnPrivateMessage);
                        } catch (TwitterException ex) {
                            error(ex.toString(), ex);
                        }
                    }
                });
            }
        }
        //**************************************************************************************

    } else {
        error("Event sensor [" + device.toString() + "] not founded in Tweetmyhome devices");
    }
}

From source file:com.tweetmyhome.TweetMyHome.java

/**
* Se ejecuta al inicio del stream (parece D=)
* @param friendIds // www  .j a  va  2  s  .  c  o  m
*/
@Override
public void onFriendList(long[] friendIds) {
    debug("onFriendList");
    try {
        db.processTwiterUsersFromTwitterIds(friendIds, tw);
        //integrityCheckSuperAdmin();
    } catch (TwitterException ex) {
        error(ex.toString(), ex);
    }
}

From source file:foo.bar.twitter.sample01.Sample01Activity.java

License:Apache License

/**
 * connect twitter/*from  www .  j a v a  2s . co m*/
 */
private void connectTwitter() {
    ConfigurationBuilder confbuilder = new ConfigurationBuilder();
    confbuilder.setOAuthConsumerKey(ConstantValue.CONSUMER_KEY);
    confbuilder.setOAuthConsumerSecret(ConstantValue.CONSUMER_SECRET);
    Configuration conf = confbuilder.build();

    twitter = new TwitterFactory(conf).getInstance();
    twitter.setOAuthAccessToken(null);

    try {
        requestToken = twitter.getOAuthRequestToken(ConstantValue.CALLBACK_URL);
        Intent intent = new Intent(this, TwitterLoginActivity.class);
        intent.putExtra(ConstantValue.IEXTRA_AUTH_URL, requestToken.getAuthorizationURL());
        this.startActivityForResult(intent, 0);
    } catch (TwitterException e) {
        Toast.makeText(this, "Twitter Exception!!\n" + e.toString(), Toast.LENGTH_LONG).show();
    }
}