Users

Returns information about a user or group of users

Twitter Users

Method: users()

Returns information about a group of users

$twitter = new BirdElephant($credentials);

$users = $twitter->users()

Lookup Users

Method: lookup()

Looks up multiple twitter users by username

$usernames = ['coderjerk', 'kennyg', 'dril'];

$params = [
    'expansions' => 'pinned_tweet_id',
    'user.fields' =>  'created_at,description,entities,id,location'
];

$users->lookup($usernames, $params);
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$usernamesArrayarray of Twitter usernamesrequired
$paramsArrayavailable query parametersoptional

Me

Method: me()

Get the authenticated user

$twitter = new BirdElephant($credentials);

$me = $twitter->me()

Method: myself()

Gets information about the authenticated user.

$params = [
    'expansions' => 'pinned_tweet_id',
];

$me->myself($params);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Twitter User

Method: user()

Sets up a Twitter user by user name to be used in conjunction with the methods below to perform actions on behalf of and retrieve data about the named user. The named user must be the authenticated user in instances where user context auth is required.

$twitter = new BirdElephant($credentials);

$user = $twitter->user($user_name);
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$user_nameStringTwitter usernamerequired

Get User

Method: get()

Gets information about the named Twitter user.

$user->get();
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Get Followers

Method: followers()

Gets a Twitter user's followers

$user->followers();
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Get Following

Method: following()

Gets a Twitter user's followed accounts

$params= [
    'max_results' => 20,
    'user.fields' => 'profile_image_url'
];

$user->following($params);
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Follow

Method: follow()

Follows a given user

$user->follow('coderjerk');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unfollow

Method: unfollow()

Unfollows a given user

$user->unfollow('stefanmross');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Timeline

Method: timeline()

Gets the authenticated user's timeline in reverse chronological order.

$username = $twitter->me()->myself()->data->username;

$timeline = $twitter->user($username)->timeline();
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

User Tweets

Method: tweets()

Gets the tweets of a Twitter user.

$user->tweets();
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Mentions

Method: mentions()

Gets the mentions of a Twitter user.

$user->mentions();
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

User Blocks

Method: blocks()

Gets the blocked accounts of a Twitter user.

$user->blocks();
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Block User

Method: block()

Blocks a given user

$user->block('GilbertOSull_');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unblock User

Method: unblock()

Unblocks a given user

$user->unblock('claydermanmusic');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

User Mutes

Method: mutes()

Gets the muted accounts of a Twitter user.

$user->mutes();
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Mute User

Method: mute()

Mutes a given user

$user->mute('kennyg');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unmute User

Method: unmute()

Unmutes a given user

$user->unmute('kennyg');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

User Likes

Method: likes()

Gets the named user's last 100 likes

$user->likes($params);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Like Tweet

Method: like()

Likes a tweet on behalf of the authenticated user

$user->like('1456978214837006343');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$tweet_idStringthe target tweet idreqired

Unlike Tweet

Method: unlike()

Unlikes a tweet on behalf of the authenticated user

$user->unlike($tweet_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

Retweet

Method: retweet()

Retweets a tweet on behalf of the authenticated user

$user->retweet('1456978214837006343');
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

Unretweet

Method: unretweet()

Unretweets a tweet on behalf of the authenticated user

$user->unretweet($tweet_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

User Spaces

Method: spaces()

Gets a user's spaces

$user->spaces();
Auth: OAuth 2.0 Bearer token
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

User Lists

Method: lists()

Perform actions on lists on behalf of the authenticated user.

$user_lists = $user->lists();

Get Followed Lists

Method: followed()

Gets a list of folllowed lists on behalf of the authenticated user

$user_lists->followed($params);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Get Pinned Lists

Gets a list of pinned lists on behalf of the authenticated user

$user_lists->pinned($params);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Get Owned Lists

Gets lists owned by the authenticated user

$user_lists->owned($params);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Follow Lists

Follows a list on behalf of the authenticated user

$user_lists->follow($target_list_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Unfollow Lists

Unfollows a list on behalf of the authenticated user

$user_lists->unfollow($target_list_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Pin Lists

Unpins a list on behalf of the authenticated user

$user_lists->pin($target_list_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Unpin Lists

Pins a list on behalf of the authenticated user

$user_lists->unpin($target_list_id);
Auth: OAuth 1.0a User context
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Reference

Refer to the Twitter documentation for details of paramaters, expansions and fields.

Edit this page on GitHub Updated at Sun, Jun 19, 2022