Get user name from Twitter, with the token provided.
@param tkn Twitter access token
@return The user found in Twitter
@throws IOException If fails
504751
private Identity identity(final String tkn) throws IOException {
        return parse(
            this.user
                .uri()
                .set(
                    URI.create(
                        new Href(PsTwitter.VERIFY_URL)
                            .with(PsTwitter.ACCESS_TOKEN, tkn)
                            .toString()
                    )
                )
                .back()
                .header("accept", "application/json")
                .fetch().as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .as(JsonResponse.class)
                .json()
                .readObject()
        );
    }
394829
public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Usage: java twitter4j.examples.list.GetUserLists [list owner screen name]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            ResponseList<UserList> lists = twitter.getUserLists(args[0]);
            for (UserList list : lists) {
                System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:"
                        + list.getDescription() + ", slug:" + list.getSlug() + "");
            }
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to list the lists: " + te.getMessage());
            System.exit(-1);
        }
    }
958444
public static function getUser()
    {
        $tweetStore = Store::get('Tweet');

        $consumerKey = Setting::getSetting('twitter', 'consumer_key');
        $consumerSecret = Setting::getSetting('twitter', 'consumer_secret');
        $accessToken = Setting::getSetting('twitter', 'access_token');
        $accessTokenSecret = Setting::getSetting('twitter', 'access_token_secret');

        $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

        if (self::canCallAPI()) {
            self::updateLastAPICall();

            $statuses = $twitter->load(Twitter::ME);
            foreach ($statuses as $s) {
                if (!$tweetStore->getByTwitterIdForScope($s->id, 'user')) {
                    $t = new Tweet;
                    $t->setTwitterId($s->id);
                    $t->setText($s->text);
                    $t->setHtmlText(Twitter::clickable($s));
                    $t->setScreenname($s->user->screen_name);
                    $t->setPosted($s->created_at);
                    $t->setCreatedDate(new \DateTime());
                    $t->setScope('user');
                    $tweetStore->saveByInsert($t);
                }
            }
        }
    }
84543
public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Usage: java twitter4j.examples.list.GetUserListSubscribers [list id]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            PagableResponseList<User> usres;
            do {
                usres = twitter.getUserListSubscribers(Integer.parseInt(args[0]), cursor);
                for (User list : usres) {
                    System.out.println("@" + list.getScreenName());
                }
            } while ((cursor = usres.getNextCursor()) != 0);
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get list subscribers: " + te.getMessage());
            System.exit(-1);
        }
    }
1345356
public static void main(String[] args) {
        if (args.length < 2) {
            System.out.println("Usage: java twitter4j.examples.list.ShowUserListMembership [list id] [user id]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long listId = Long.parseLong(args[0]);
            UserList list = twitter.showUserList(listId);
            long userId = Integer.parseInt(args[1]);
            User user = twitter.showUser(userId);
            try {
                twitter.showUserListMembership(listId, userId);
                System.out.println("@" + user.getScreenName() + " is in the list:" + list.getName());
            } catch (TwitterException te) {
                if (te.getStatusCode() == 404) {
                    System.out.println("@" + user.getScreenName() + " is not in the list:" + list.getName());
                }
            }
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to check user membership: " + te.getMessage());
            System.exit(-1);
        }
    }
90142
public String nextName() throws IOException {
        peek();
        if (token != JsonToken.NAME) {
            throw new IllegalStateException("Expected a name but was " + peek());
        }
        String result = name;
        advance();
        return result;
    }
932652
public String getUserName(boolean notAlternateUser) 
  {
    if (tc.isEntryEnabled()) 
       SibTr.entry(tc, "getUserName", 
         new Object[]{new Boolean(notAlternateUser)});
                   
    String userName = null;
    
    if(!notAlternateUser // this catches the case where we want the
                         // user associated with the subject
       && isAlternateUserBased())                             
    {       
      userName = alternateUser;
    }
    else if(isSubjectBased())
    {     
      if(authorisationUtils != null)
      {
        userName = authorisationUtils.getUserName(subject);
      }      
    }
    else if(isUserIdBased())
    {       
      userName = userId;
    }
    else if(isMsgBased())
    {       
      userName = msg.getSecurityUserid();
    }
 
    if (tc.isEntryEnabled()) 
       SibTr.exit(tc, "getUserName", userName);        
    return userName;
  }
504489
private static Token<EsTokenIdentifier> getAuthToken(ClusterName clusterName, User user) {
        EsToken esToken = getEsAuthToken(clusterName, user);
        if (esToken == null) {
            return null;
        } else {
            return EsTokenIdentifier.createTokenFrom(esToken);
        }
    }
1064678
def tweet(*args)
      load_default_token
      # get it from them directly
      tweet_text = args.join(' ').strip
      # or let them append / or pipe
      tweet_text += (tweet_text.empty? ? '' : ' ') + STDIN.read unless STDIN.tty?
      # or let them get prompted for it
      if tweet_text.empty?
        print 'Tweet (Press return to finish): '
        tweet_text = STDIN.gets.strip
      end
      return failtown("Empty Tweet") if tweet_text.empty?
      return failtown("Tweet is too long!") if tweet_text.scan(/./mu).size > 140
      return failtown("Unauthorized, re-run setup!") unless @client && @client.authorized?
      # actually post it
      @client.update(tweet_text)
      puts "Tweet Posted!"
    end
818741
public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Usage: java twitter4j.examples.list.GetUserListMemberships [list member screen name]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            PagableResponseList<UserList> lists;
            do {
                lists = twitter.getUserListMemberships(args[0], cursor);
                for (UserList list : lists) {
                    System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:"
                            + list.getDescription() + ", slug:" + list.getSlug() + "");
                }
            } while ((cursor = lists.getNextCursor()) != 0);
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to list the lists: " + te.getMessage());
            System.exit(-1);
        }
    }
645630
public static String getUserNameFromToken(String authToken) {
        if (null == authToken) {
            return null;
        }

        return authToken.split(TOKEN_SEPARATOR)[0];
    }
755039
public Iterable<DContact> queryByTwitter(Object parent, java.lang.String twitter) {
    return queryByField(parent, DContactMapper.Field.TWITTER.getFieldName(), twitter);
  }
440021
@Override
    public void getOAuthRequestTokenAsync() {
        getDispatcher().invokeLater(new AsyncTask(OAUTH_REQUEST_TOKEN, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                RequestToken token = twitter.getOAuthRequestToken();
                for (TwitterListener listener : listeners) {
                    try {
                        listener.gotOAuthRequestToken(token);
                    } catch (Exception e) {
                        logger.warn("Exception at getOAuthRequestTokenAsync", e);
                    }
                }
            }
        });
    }
1304773
@SuppressWarnings("unchecked")
    @Override
	public <T extends ApiUser> T getUserById(int id) {
	    User sfsUser = getZone().getUserById(id);
	    if(sfsUser != null && sfsUser.containsProperty(APIKey.USER))
	        return (T) sfsUser.getProperty(APIKey.USER);
	    return null;
	}
29132
public static void setUsername(final String username) {
        if (username == null) {
            throw new AuthenticationException("Username can not be null");
        }

        if (!username.equals(Twilio.username)) {
            Twilio.invalidate();
        }

        Twilio.username = username;
    }
391318
public boolean nextValidToken() throws IOException {
        while (tokeniser.nextToken()) {
            if (tokeniser.getTokenType() == PRTokeniser.TK_COMMENT)
                continue;
            return true;
        }
        return false;
    }
545498
public RTMClient rtmConnect(String apiToken, boolean fullUserInfoRequired) throws IOException {
        try {
            RTMConnectResponse response = methods().rtmConnect(RTMConnectRequest.builder().token(apiToken).build());
            if (response.isOk()) {
                User connectedBotUser = response.getSelf();
                if (fullUserInfoRequired) {
                    String userId = response.getSelf().getId();
                    UsersInfoResponse resp = this.methods().usersInfo(UsersInfoRequest.builder().token(apiToken).user(userId).build());
                    if (resp.isOk()) {
                        connectedBotUser = resp.getUser();
                    } else {
                        String errorMessage = "Failed to get fill user info (user id: " + response.getSelf().getId() + ", error: " + resp.getError() + ")";
                        throw new IllegalStateException(errorMessage);
                    }
                }
                return new RTMClient(this, apiToken, response.getUrl(), connectedBotUser);
            } else {
                throw new IllegalStateException("Failed to the RTM endpoint URL (error: " + response.getError() + ")");
            }
        } catch (SlackApiException e) {
            throw new IllegalStateException(
                    "Failed to connect to the RTM API endpoint. (" +
                            "status: " + e.getResponse().code() + ", " +
                            "error: " + e.getError().getError() +
                            ")", e);
        } catch (URISyntaxException e) {
            throw new IllegalStateException(
                    "Failed to connect to the RTM API endpoint. (message: " + e.getMessage() + ")", e);
        }
    }