コード例 #1
0
    private void completeVerify(Uri uri) {
      SoomlaUtils.LogDebug(TAG, "Verification complete");
      /** Handle OAuth Callback */
      if (uri != null && uri.toString().startsWith(oauthCallbackURL)) {
        String verifier = uri.getQueryParameter(OAUTH_VERIFIER);
        if (!TextUtils.isEmpty(verifier)) {
          twitter.getOAuthAccessTokenAsync(mainRequestToken, verifier);
        } else {
          // Without a verifier an Access Token cannot be received
          // happens when a user clicks "cancel"
          cancelLogin();
        }
      }

      webView.hide();
      finish();

      mFinishedVerifying = true;
    }
コード例 #2
0
  public static void getAccessTokensForPIN(String PIN) {
    final AsyncTwitter twitter = getAsyncInstance();
    twitter.addListener(
        new TwitterAdapter() {
          @Override
          public void gotOAuthAccessToken(AccessToken token) {
            AIR.log("Retrieved access tokens");
            /* Store access tokens */
            TwitterAPI.storeAccessTokens(token);
            AIR.dispatchEvent(AIRTwitterEvent.LOGIN_SUCCESS);
          }

          @Override
          public void onException(TwitterException te, TwitterMethod method) {
            if (method == TwitterMethod.OAUTH_ACCESS_TOKEN) {
              AIR.dispatchEvent(
                  AIRTwitterEvent.LOGIN_ERROR, StringUtils.removeLineBreaks(te.getMessage()));
            }
          }
        });
    twitter.getOAuthAccessTokenAsync(mRequestToken, PIN);
  }