public class Twitter_Users
extends java.lang.Object
Twitter.users()
to get one of these objects.
Conceptually, this is an extension of Twitter
. The methods are here
because Twitter was getting crowded.
Modifier and Type | Method and Description |
---|---|
User |
block(java.lang.String screenName)
blocks/create: Blocks screenName from following the authenticating user.
|
User |
follow(java.lang.String username)
Start following a user.
|
User |
follow(User user)
Convenience for
follow(String) |
java.util.List<java.lang.Number> |
getBlockedIds() |
ListWithCursor<java.lang.Number> |
getFollowerIDs()
Returns the IDs of the authenticating user's followers.
|
ListWithCursor<java.lang.Number> |
getFollowerIDs(long userId)
Returns the IDs of the specified user's followers.
|
ListWithCursor<java.lang.Number> |
getFollowerIDs(java.lang.String screenName)
Returns the IDs of the specified user's followers.
|
java.util.List<User> |
getFollowers()
Deprecated.
Twitter advise using
getFollowerIDs() and
show(Number) |
java.util.List<User> |
getFollowers(java.lang.String username)
Deprecated.
Only available in v1.0 API (due to switch off soon).
Returns the (latest 100) given user's followers, each with current status
inline. Occasionally contains duplicates.
|
ListWithCursor<java.lang.Number> |
getFriendIDs()
Returns the IDs of the authenticating user's friends.
|
ListWithCursor<java.lang.Number> |
getFriendIDs(long userId)
Returns the IDs of the specified user's friends.
|
ListWithCursor<java.lang.Number> |
getFriendIDs(java.lang.String screenName)
Returns the IDs of the specified user's friends.
|
java.util.List<User> |
getFriends()
Deprecated.
Twitter advise you to use
getFriendIDs() with
Twitter_Users#showById(List) instead. |
java.util.List<User> |
getFriends(java.lang.String username)
Deprecated.
Only available in v1.0 API (due to switch off soon).
Returns the (latest 100) given user's friends (people *they* follow),
each with current status inline. Occasionally contains duplicates.
|
java.util.List<User> |
getRelationshipInfo(java.util.List<java.lang.String> screenNames)
Bulk-fetch relationship info by screen-name.
|
java.util.List<User> |
getRelationshipInfoById(java.util.List<? extends java.lang.Number> userIDs)
Bulk-fetch relationship info by user-id.
|
User |
getUser(long userId)
Synonym for
#show(long) . |
User |
getUser(java.lang.String screenName)
Synonym for
show(String) . |
boolean |
isBlocked(java.lang.Long userId) |
boolean |
isBlocked(java.lang.String screenName) |
boolean |
isFollower(java.lang.String userB)
Is the authenticating user followed by userB?
|
boolean |
isFollower(java.lang.String followerScreenName,
java.lang.String followedScreenName) |
boolean |
isFollowing(java.lang.String userB)
Does the authenticating user follow userB?
|
boolean |
isFollowing(User user)
Convenience for
isFollowing(String) |
User |
leaveNotifications(java.lang.String screenName)
Deprecated.
v1.0 method, now simulated
|
User |
notify(java.lang.String username)
Enables notifications for updates from the specified user who must
already be a friend.
|
User |
reportSpammer(java.lang.String screenName) |
java.util.List<User> |
searchUsers(java.lang.String searchTerm)
Warning: there is a bug within twitter.com which means that
location-based searches are treated as OR.
|
java.util.List<User> |
searchUsers(java.lang.String searchTerm,
int page)
Variant of
searchUsers(String) which gives access to later pages. |
Twitter_Users |
setCursor(java.lang.String cursor)
Set the cursor used by
getFollowerIDs() , getFriendIDs() and related methods. |
User |
setNotifications(java.lang.String screenName,
java.lang.Boolean device,
java.lang.Boolean retweets) |
java.util.List<User> |
show(java.util.Collection<java.lang.String> screenNames)
Lookup user info.
|
User |
show(java.lang.Number userId)
Returns information of a given user, specified by user-id.
|
User |
show(java.lang.String screenName)
Returns information of a given user, specified by screen name.
|
java.util.List<User> |
showById(java.util.Collection<? extends java.lang.Number> userIds)
Lookup user info.
|
User |
stopFollowing(java.lang.String username)
Destroy: Discontinues friendship with the user specified in the ID
parameter as the authenticating user.
|
User |
stopFollowing(User user)
Convenience for
stopFollowing(String) |
User |
unblock(java.lang.String screenName)
blocks/destroy: Un-blocks screenName for the authenticating user.
|
boolean |
userExists(java.lang.String screenName)
Does a user with the specified name or id exist?
|
public User block(java.lang.String screenName)
screenName
- unblock(String)
public User follow(java.lang.String username) throws TwitterException
username
- Required. The ID or screen name of the user to befriend.TwitterException
- if the user does not exist or has been suspended.stopFollowing(String)
public User follow(User user)
follow(String)
user
- public java.util.List<java.lang.Number> getBlockedIds()
showById(Collection)
if you want to convert thse
into User objects.public ListWithCursor<java.lang.Number> getFollowerIDs() throws TwitterException
TwitterException
public ListWithCursor<java.lang.Number> getFollowerIDs(java.lang.String screenName) throws TwitterException
screenName
- The screen name of the user whose followers are to be fetched.TwitterException
public ListWithCursor<java.lang.Number> getFollowerIDs(long userId) throws TwitterException
userId
- The id of the user whose followers are to be fetched.TwitterException
@Deprecated public java.util.List<User> getFollowers() throws TwitterException
getFollowerIDs()
and
show(Number)
TwitterException
public java.util.List<User> getFollowers(java.lang.String username) throws TwitterException
username
- The screen name of the user for whom to request a list of
friends.TwitterException
public ListWithCursor<java.lang.Number> getFriendIDs() throws TwitterException
TwitterException
public ListWithCursor<java.lang.Number> getFriendIDs(java.lang.String screenName) throws TwitterException
screenName
- The screen name of the user whose friends are to be fetched.TwitterException
public ListWithCursor<java.lang.Number> getFriendIDs(long userId) throws TwitterException
userId
- The id of the user whose friends are to be fetched.TwitterException
@Deprecated public java.util.List<User> getFriends() throws TwitterException
getFriendIDs()
with
Twitter_Users#showById(List)
instead.Note that there seems to be a small delay from Twitter in updates to this list.
TwitterException
getFriendIDs()
,
isFollowing(String)
public java.util.List<User> getFriends(java.lang.String username) throws TwitterException
username
- The screen name of the user for whom to request a list of
friends.TwitterException
#getFriendIDs(String)}
public java.util.List<User> getRelationshipInfo(java.util.List<java.lang.String> screenNames)
screenNames
- Can be emptyUser.isFollowingYou()
and User.isFollowedByYou()
set (plus name, screenname and id).getRelationshipInfoById(List)
public java.util.List<User> getRelationshipInfoById(java.util.List<? extends java.lang.Number> userIDs)
userIDs
- Can be emptyUser.isFollowingYou()
and User.isFollowedByYou()
set (plus name, screenname and id).getRelationshipInfo(List)
public User getUser(long userId)
#show(long)
. show is the Twitter API name, getUser
feels more Java-like.userId
- The user-id of a user.getUser(String)
public User getUser(java.lang.String screenName)
show(String)
. show is the Twitter API name, getUser
feels more Java-like.screenName
- The screen name of a user.public Twitter_Users setCursor(java.lang.String cursor)
getFollowerIDs()
, getFriendIDs()
and related methods.
If you set this, be careful to unset it, or use a fresh Twitter_Users
object.cursor
- Can be null or -1 for "first page".public boolean isBlocked(java.lang.Long userId)
public boolean isBlocked(java.lang.String screenName)
public boolean isFollower(java.lang.String userB)
userB
- The screen name of a Twitter user.public boolean isFollower(java.lang.String followerScreenName, java.lang.String followedScreenName)
TwitterException.E403
- if one of the users has protected their updates and you don't
have access. This can be counter-intuitive (and annoying) at
times! Also throws E403 if one of the users has been
suspended (we use the TwitterException.SuspendedUser
exception
sub-class for this).TwitterException.E404
- if one of the users does not existpublic boolean isFollowing(java.lang.String userB)
userB
- The screen name of a Twitter user.public boolean isFollowing(User user)
isFollowing(String)
user
- public User leaveNotifications(java.lang.String screenName)
screenName
- Stop getting notifications from this user, who must already be
one of your friends.Switches off notifications for updates from the specified user who
must already be a friend.
public User setNotifications(java.lang.String screenName, java.lang.Boolean device, java.lang.Boolean retweets)
screenName
- device
- Can be null (for do not change)retweets
- Can be null (for do not change)public User notify(java.lang.String username)
username
- Get notifications from this user, who must already be one of
your friends.public User reportSpammer(java.lang.String screenName)
public java.util.List<User> searchUsers(java.lang.String searchTerm)
Unlike tweet search, this method does not support any operators. Only the first 1000 matches are available.
Does not do paging-to-max-results. But does support using
#setPageNumber(Integer)
.
Can use #setMaxResults(int)
for less than the standard 20.
Rate-limit: RateLimit.RES_USERS_SEARCH
searchTerm
- public java.util.List<User> searchUsers(java.lang.String searchTerm, int page)
searchUsers(String)
which gives access to later pages.
Note: You can only access upto the first 1000 matching results (a Twitter limitation
-- c.f. https://dev.twitter.com/docs/api/1.1/get/users/search).searchTerm
- Does not support OR, "quotes". Does support -term for not.page
- Which page to retrieve (the first page is 1)public java.util.List<User> show(java.util.Collection<java.lang.String> screenNames)
screenNames
- Can be empty (in which case we avoid wasting an API call).
Bogus names & deleted users will be quietly filtered out.#showById(List)
public User show(java.lang.Number userId)
userId
- The user-id of a user.exception
- if the user does not exist - or has been terminated (as
happens to spam bots).public User show(java.lang.String screenName) throws TwitterException, TwitterException.SuspendedUser
screenName
- The screen name of a user.exception
- if the user does not existTwitterException.SuspendedUser
- if the user has been terminated (as happens to spam bots).TwitterException
#show(long)
public java.util.List<User> showById(java.util.Collection<? extends java.lang.Number> userIds)
#show(List)
, but works with Twitter
user-ID numbers. Done in batches of 100, limited to 1000 an hour.userIds
- . Can be empty (in which case we avoid making a wasted API
call).public User stopFollowing(java.lang.String username)
username
- The screen name of the user with whom to discontinue
friendship.public User stopFollowing(User user)
stopFollowing(String)
user
- public User unblock(java.lang.String screenName)
screenName
- block(String)
public boolean userExists(java.lang.String screenName)
screenName
- The screen name or user id of the suspected user.