Example usage for twitter4j AsyncTwitter verifyCredentials

List of usage examples for twitter4j AsyncTwitter verifyCredentials

Introduction

In this page you can find the example usage for twitter4j AsyncTwitter verifyCredentials.

Prototype

void verifyCredentials();

Source Link

Document

Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not.

Usage

From source file:com.marpies.ane.twitter.functions.InitFunction.java

License:Apache License

@Override
public FREObject call(FREContext context, FREObject[] args) {
    super.call(context, args);

    if (TwitterAPI.isInitialized())
        return null;

    String consumerKey = FREObjectUtils.getString(args[0]);
    String consumerSecret = FREObjectUtils.getString(args[1]);
    String urlScheme = FREObjectUtils.getString(args[2]);
    Boolean showLogs = FREObjectUtils.getBoolean(args[3]);

    AIR.setLogEnabled(showLogs);/*from   w  w  w . j a v a 2  s .  co  m*/

    TwitterAPI.init(consumerKey, consumerSecret, urlScheme);

    /* Verify cached access tokens */
    if (TwitterAPI.hasAccessTokens()) {
        AIR.log("Verifying credentials");
        AsyncTwitter twitter = TwitterAPI.getAsyncInstance(TwitterAPI.getAccessToken());
        twitter.addListener(this);
        twitter.verifyCredentials();
    } else {
        AIR.dispatchEvent(AIRTwitterEvent.CREDENTIALS_CHECK, "{ \"result\": \"missing\" }");
    }

    return null;
}