PHPackages                             coderjerk/elephant-bird - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. coderjerk/elephant-bird

Abandoned → [coderjerk/bird-elephant](/?search=coderjerk%2Fbird-elephant)ArchivedLibrary[API Development](/categories/api)

coderjerk/elephant-bird
=======================

A simple library to request data from the Twitter APIv2 endpoints

v1.5.1(5y ago)030MITPHP

Since Oct 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/danieldevine/eb)[ Packagist](https://packagist.org/packages/coderjerk/elephant-bird)[ RSS](/packages/coderjerk-elephant-bird/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (14)Used By (0)

Elephant Bird - DEPRECTATED
===========================

[](#elephant-bird---deprectated)

**Deprecated as of Nov 2021 - please use Bird Elephant instead - its much improved!**This will recieve security patches only from now on.
-----------------------------------------------------------------------------------------------------------------------------------------

[](#deprecated-as-of-nov-2021---please-use-bird-elephant-instead---its-much-improvedthis-will-recieve-security-patches-only-from-now-on)

**Note**: This package currently caters for **bearer token based app access only**. [I'm @coderjerk on Twitter if you want to discuss.](https://twitter.com/coderjerk)

These endpoints are early access so subject to change. This package does not support old v1.1 endpoints.

#### Currently supported:

[](#currently-supported)

- API v2
    - Tweets
        - Recent Search
        - Lookup
        - Filtered Stream (basic support)
        - Timeline
    - Users
        - Follows Lookup
        - User Lookup

To use this package you must have an approved developer account, and have activated the new developer portal.

Learn more about getting access to the Twitter API v2 endpoints:

[Twitter Getting Started Docs](https://developer.twitter.com/en/docs/twitter-api/getting-started/guide)

### API Reference

[](#api-reference)

[Twitter Recent Search Endpoint API Reference](https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent)

[Lookup Multiple Tweets API Reference](https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets)

[Lookup Single Tweets API Reference](https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id)

Note that operator support is quite sparse at the moment which makes the use of tweets and media more than a little risky in some contexts - for example filtering NSFW content is not yet possible. I don't know if this is in Twitter's plans or not.

Install:
--------

[](#install)

Install via composer.

```
$ composer require coderjerk/elephant-bird
```

Auth
----

[](#auth)

Bearer token support only for now. Copy the contents of .env.example to .env in your project and populate with your own credentials that you have set up for your project in the Twitter dev portal. If you aren't using .env in your project, you will need to set it up, [details here](https://github.com/vlucas/phpdotenv)

Examples:
---------

[](#examples)

#### Recent Search

[](#recent-search)

Search the 14 most recent tweets relating to football.

```
use Coderjerk\ElephantBird\RecentSearch;

$params = [
    'query'        => 'football',
    'max_results'  => 14,
];

$search = new RecentSearch;
$result = $search->RecentSearchRequest($params);

$tweets = $result->data;
```

Search for media:

```
use Coderjerk\ElephantBird\RecentSearch;

$params = [
    'query' => 'dancing has:images ',
    'tweet.fields' => 'attachments,author_id,created_at',
    'expansions'   => 'attachments.media_keys',
    'media.fields' => 'public_metrics,type,url,width',
    'max_results'  => 10,
];

$search = new RecentSearch;
$result = $search->RecentSearchRequest($params);
$media = $result->includes->media;
```

#### Tweet Lookup

[](#tweet-lookup)

Lookup details about multiple tweets by Id - if a single id is provided Elephant Bird will choose the single tweet endpoint:

```
use Coderjerk\ElephantBird\TweetLookup;

$ids = [
    '1261326399320715264',
    '1278347468690915330'
];

$params = [
    'tweet.fields' => 'attachments,author_id,created_at,public_metrics,source'
];

$lookup = new TweetLookup;
$tweets = $lookup->getTweetsById($ids, $params);
```

#### Timeline

[](#timeline)

Get a given user's Tweets.

```
use Coderjerk\ElephantBird\TimeLine;

$timeline = new TimeLine;

$params = [
    'tweet.fields' => 'attachments,author_id,created_at,public_metrics,source'
];

$tweets = $timeline->getTweets('802448659', $params);
```

Get a given user's mentions.

```
use Coderjerk\ElephantBird\TimeLine;

$timeline = new TimeLine;

$params = [
    'tweet.fields' => 'attachments,author_id,created_at,public_metrics,source'
];

$mentions = $timeline->getMentions('802448659', $params);
```

#### User Lookup

[](#user-lookup)

Lookup a single user by username:

```
use Coderjerk\ElephantBird\UserLookup;

$params = [
    'user.fields' => 'id'
];

$usernames = [
    'coderjerk'
];

$userLookup = new UserLookup;
$user = $userLookup->lookupUsersByUsername($usernames, $params);
```

Lookup multiple users by id:

```
use Coderjerk\ElephantBird\UserLookup;

$ids = [
    '802448659',
    '16298441'
];

$userLookup = new UserLookup;
$user = $userLookup->lookupUsersById($ids, $params);
```

#### Follows Lookup

[](#follows-lookup)

Get Followers

```
use Coderjerk\ElephantBird\FollowsLookup;

$follows = new FollowsLookup;

$params = [
    'tweet.fields' => 'attachments,author_id,created_at,public_metrics,source'
];

$followers = $follows->getFollowers('802448659', $params);
```

Get Following

```
use Coderjerk\ElephantBird\FollowsLookup;

$follows = new FollowsLookup;

$params = [
    'tweet.fields' => 'attachments,author_id,created_at,public_metrics,source'
];

$following = $follows->getFollowing('802448659', $params);
```

Contributing
------------

[](#contributing)

Fork/download the code and run `composer install`

This package is in the early stages of development. Issues, pull requests and other contributions most welcome.

You can [look at the project board here for upcoming features:](https://github.com/danieldevine/elephant-bird/projects/1)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~92 days

Total

12

Last Release

1656d ago

Major Versions

v1.5.1 → v2.x-dev2021-11-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/57a1b0f82fadf970d1068cd30fd72f6e85ea2abe3fc9e3ff082b32381e42db8f?d=identicon)[Coderjerk](/maintainers/Coderjerk)

---

Top Contributors

[![danieldevine](https://avatars.githubusercontent.com/u/5939939?v=4)](https://github.com/danieldevine "danieldevine (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coderjerk-elephant-bird/health.svg)

```
[![Health](https://phpackages.com/badges/coderjerk-elephant-bird/health.svg)](https://phpackages.com/packages/coderjerk-elephant-bird)
```

###  Alternatives

[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
