DigitsApiClient getApiClient(Session session) {
    if (digitsApiClient != null && digitsApiClient.getSession().equals(session)) {
      return digitsApiClient;
    }

    digitsApiClient =
        new DigitsApiClient(
            session,
            twitterCore.getAuthConfig(),
            twitterCore.getSSLSocketFactory(),
            digits.getExecutorService(),
            new DigitsUserAgent(digits.getVersion(), Build.VERSION.RELEASE));

    return digitsApiClient;
  }
  /** 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();
          }
        });
  }
 private void startSignUpWithBundle(AuthCallback callback, Bundle bundle) {
   final DigitsSession session = sessionManager.getActiveSession();
   digits.getScribeService().dailyPing();
   if (session != null && !session.isLoggedOutUser()) {
     callback.success(session, null);
   } else {
     startPhoneNumberActivity(twitterCore.getContext(), bundle);
   }
 }
  @Test
  public void testBuildCallbackUrl() {
    final String callbackUrl = service.buildCallbackUrl(authConfig);

    assertEquals(
        String.format(
            "twittersdk://callback?version=%s&app=%s",
            twitterCore.getVersion(), authConfig.getConsumerKey()),
        callbackUrl);
  }
Exemplo n.º 5
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();
              }
            });
  }
 @Test
 public void testGetUserAgent() {
   final String userAgent =
       TwitterApi.buildUserAgent("TwitterAndroidSDK", twitterCore.getVersion());
   assertEquals(userAgent, service.getUserAgent());
 }
 DigitsClient() {
   this(Digits.getInstance(), TwitterCore.getInstance(), Digits.getSessionManager(), null);
 }