1followers <- function(user_id, n=NULL, ...) {
2  ffBase('followers', user_id, n, ...)
3}
4
5friends <- function(user_id, n=NULL, ...) {
6  ffBase('friends', user_id, n, ...)
7}
8
9ffBase <- function(type, user_id, n=NULL, ...) {
10  if (!can_access_other_account(user_id)) {
11    warning("Cannot lookup relationships for user id ", user_id, ", query may fail!")
12  }
13  params <- parseUsers(user_id)
14  doCursorAPICall(paste(type, 'ids', sep='/'), 'ids', num=n, params=params, method='GET', ...)
15}
16
17friendships = function(screen_names=character(), user_ids=character(), ...) {
18  if ((length(user_ids) + length(screen_names)) > 100) {
19    stop("friendships() has a maximum of 100 total user ids and screen names")
20  }
21
22  user_list = buildUserList(user_ids, screen_names)
23
24  friendships = twInterfaceObj$doAPICall("friendships/lookup", params=user_list, ...)
25  friendship_dfs = lapply(friendships, function(x) {
26    following = "following" %in% x$connections
27    followed_by = "followed_by" %in% x$connections
28    return(c(name=x$name, screen_name=x$screen_name, id=x$id_str, following=following,
29             followed_by=followed_by))
30  })
31
32  return(as.data.frame(do.call(rbind, friendship_dfs), stringsAsFactors=FALSE))
33}