Search in sources :

Example 1 with TwitterAdapter

use of com.dexels.twitter.TwitterAdapter in project navajo by Dexels.

the class CheckTwitterToken method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    if (operand(0) == null)
        return null;
    String token1 = getStringOperand(0);
    String token2 = getStringOperand(1);
    if (token1 == null || token2 == null) {
        return false;
    }
    TwitterAdapter ta = new TwitterAdapter();
    ta.setToken1(token1);
    ta.setToken2(token2);
    try {
        ta.getStatus();
    } catch (TwitterException te) {
        if (te.getMessage().indexOf("code 89") > -1) {
            return false;
        }
        // an invalid account (code 89).
        return false;
    }
    return true;
}
Also used : TwitterAdapter(com.dexels.twitter.TwitterAdapter) TwitterException(winterwell.jtwitter.TwitterException)

Aggregations

TwitterAdapter (com.dexels.twitter.TwitterAdapter)1 TwitterException (winterwell.jtwitter.TwitterException)1