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);
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);
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);
ArgumentTypeDescription
$user_nameStringTwitter usernamerequired

Get User

Method: get()

Gets information about the named Twitter user.

$user->get();
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Get Followers

Method: followers()

Gets a Twitter user's followers

$user->followers();
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);
ArgumentTypeDescription
$paramsArrayavailable query parametersoptional

Follow

Method: follow()

Follows a given user

$user->follow('coderjerk');
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unfollow

Method: unfollow()

Unfollows a given user

$user->unfollow('stefanmross');
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();
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

User Tweets

Method: tweets()

Gets the tweets of a Twitter user.

$user->tweets();
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Mentions

Method: mentions()

Gets the mentions of a Twitter user.

$user->mentions();
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

User Blocks

Method: blocks()

Gets the blocked accounts of a Twitter user.

$user->blocks();
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Block User

Method: block()

Blocks a given user

$user->block('GilbertOSull_');
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unblock User

Method: unblock()

Unblocks a given user

$user->unblock('claydermanmusic');
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

User Mutes

Method: mutes()

Gets the muted accounts of a Twitter user.

$user->mutes();
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Mute User

Method: mute()

Mutes a given user

$user->mute('kennyg');
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

Unmute User

Method: unmute()

Unmutes a given user

$user->unmute('kennyg');
ArgumentTypeDescription
$target_usernameStringThe target twitter usernamerequired

User Likes

Method: likes()

Gets the named user's last 100 likes

$user->likes($params);
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Like Tweet

Method: like()

Likes a tweet on behalf of the authenticated user

$user->like('1456978214837006343');
ArgumentTypeDescription
$tweet_idStringthe target tweet idreqired

Unlike Tweet

Method: unlike()

Unlikes a tweet on behalf of the authenticated user

$user->unlike($tweet_id);
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

Retweet

Method: retweet()

Retweets a tweet on behalf of the authenticated user

$user->retweet('1456978214837006343');
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

Unretweet

Method: unretweet()

Unretweets a tweet on behalf of the authenticated user

$user->unretweet($tweet_id);
ArgumentTypeDescription
$tweet_idStringthe target tweet idrequired

User Spaces

Method: spaces()

Gets a user's spaces

$user->spaces();
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);
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);
ArgumentTypeDescription
$paramsArraysee Twitter docs for avilable query parametersoptional

Get Owned Lists

Gets lists owned by the authenticated user

$user_lists->owned($params);
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);
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Unfollow Lists

Unfollows a list on behalf of the authenticated user

$user_lists->unfollow($target_list_id);
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Pin Lists

Unpins a list on behalf of the authenticated user

$user_lists->pin($target_list_id);
ArgumentTypeDescription
$target_list_idStringThe target list idrequired

Unpin Lists

Pins a list on behalf of the authenticated user

$user_lists->unpin($target_list_id);
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 Tue, Jan 3, 2023