/** hacemos la peticion de lista de tweets */
  private void getTweets(Long id) {

    TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
    StatusesService statusesService = twitterApiClient.getStatusesService();
    statusesService.userTimeline(
        id,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        new Callback<List<Tweet>>() {
          @Override
          public void success(Result<List<Tweet>> result) {

            updateUI(result.data);
          }

          public void failure(TwitterException exception) {
            // Do something on failure
            exception.printStackTrace();
          }
        });
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TwitterCore.getInstance()
        .logInGuest(
            new Callback<AppSession>() {
              @Override
              public void success(Result<AppSession> result) {
                AppSession guestAppSession = result.data;

                TwitterApiClient twitterApiClient =
                    TwitterCore.getInstance().getApiClient(guestAppSession);
                twitterApiClient
                    .getSearchService()
                    .tweets(
                        "#fabric",
                        null,
                        null,
                        null,
                        null,
                        50,
                        null,
                        null,
                        null,
                        true,
                        new Callback<Search>() {
                          @Override
                          public void success(Result<Search> result) {
                            // use result tweets
                          }

                          @Override
                          public void failure(TwitterException exception) {
                            final TwitterApiException apiException =
                                (TwitterApiException) exception;
                            final int errorCode = apiException.getErrorCode();
                            if (errorCode == TwitterApiConstants.Errors.APP_AUTH_ERROR_CODE
                                || errorCode == TwitterApiConstants.Errors.GUEST_AUTH_ERROR_CODE) {
                              // get new guestAppSession
                              // optionally retry
                            }
                          }
                        });
              }

              @Override
              public void failure(TwitterException e) {
                e.printStackTrace();
              }
            });
  }
 DigitsClient() {
   this(Digits.getInstance(), TwitterCore.getInstance(), Digits.getSessionManager(), null);
 }