PHPackages                             zendframework/zendservice-twitter - 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. zendframework/zendservice-twitter

Abandoned → [laminas/laminas-twitter](/?search=laminas%2Flaminas-twitter)ArchivedLibrary[API Development](/categories/api)

zendframework/zendservice-twitter
=================================

OOP wrapper for the Twitter web service

3.0.4(7y ago)22208.3k↑100%19[2 issues](https://github.com/zendframework/ZendService_Twitter/issues)6BSD-3-ClausePHPPHP ^7.1

Since Jul 23Pushed 6y ago6 watchersCompare

[ Source](https://github.com/zendframework/ZendService_Twitter)[ Packagist](https://packagist.org/packages/zendframework/zendservice-twitter)[ RSS](/packages/zendframework-zendservice-twitter/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)Dependencies (8)Versions (19)Used By (6)

zendservice-twitter
===================

[](#zendservice-twitter)

> ## Repository abandoned 2019-12-31
>
> [](#repository-abandoned-2019-12-31)
>
> This repository has moved to [laminas/laminas-twitter](https://github.com/laminas/laminas-twitter).

[![Build Status](https://camo.githubusercontent.com/fbae5b4a5c48baf2c15ddc6ebb539852f3cf6860ac2c970c71f94a232998acaf/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f7a656e646672616d65776f726b2f5a656e64536572766963655f547769747465722e7376673f6272616e63683d6d6173746572)](https://secure.travis-ci.org/zendframework/ZendService_Twitter)[![Coverage Status](https://camo.githubusercontent.com/4e53452786a8314109bdc61ca393c85a816e07e16e52cf558fac7592af2773f8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7a656e646672616d65776f726b2f5a656e64536572766963655f547769747465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/zendframework/ZendService_Twitter?branch=master)

Provides an object oriented PHP wrapper for the [Twitter API](https://developer.twitter.com/en/docs).

Installation
------------

[](#installation)

Run the following to install this library:

```
$ composer require zendframework/zendservice-twitter
```

Usage
-----

[](#usage)

Instantiate the `Twitter` class by providing your Twitter consumer key and secret, as well as the access token and secret:

```
use ZendService\Twitter\Twitter;

$twitter = new Twitter([
    'access_token' => [
        'token' => '',
        'secret' => '',
    ],
    'oauth_options' => [
        'consumerKey' => '',
        'consumerSecret' => '',
    ],
]);
```

Once you have done that, you may start making calls to the API. This can be done in one of three ways:

- Using direct method calls on the `Twitter` class. A full list is provided below.
- Using the "proxy" functionality. In these cases, you will provide the first path element of the API, and then call a method on it: `$twitter->statuses->update($message)`.
- Using the `get()` or `post()` methods.

Available methods
-----------------

[](#available-methods)

- `accountVerifyCredentials() : Response`
- `applicationRateLimitStatus() : Response`
- `blocksCreate($id) : Response`
- `blocksDestroy($id) : Response`
- `blocksIds(int $cursor = -1) : Response`
- `blocksList(int $cursor = -1) : Response`
- `directMessagesDestroy($id) : Response`
- `directMessagesMessages(array $options = []) : Response`
- `directMessagesNew($user, string $text, array $extraParams = []) : Response`
- `directMessagesEventsNew($user, string $text, array $extraParams = []) : Response`
- `directMessagesSent(array $options = []) : Response`
- `favoritesCreate($id) : Response`
- `favoritesDestroy($id) : Response`
- `favoritesList(array $options = []) : Response`
- `followersIds($id, array $params = []) : Response`
- `friendsIds($id, array $params = []) : Response`
- `friendshipsCreate($id, array $params = []) : Response`
- `friendshipsLookup($id, array $params = []) : Response`
- `friendshipsDestroy($id) : Response`
- `listsMembers($listIdOrSlug, array $params = []) : Response`
- `listsMemberships($id, array $params = []) : Response`
- `listsSubscribers($id, array $params = []) : Response`
- `searchTweets(string $query, array $options = []) : Response`
- `statusesDestroy($id) : Response`
- `statusesHomeTimeline(array $options = []) : Response`
- `statusesMentionsTimeline(array $options = []) : Response`
- `statusesSample() : Response`
- `statusesShow($id, array $options = []) : Response`
- `statusesUpdate(string $status, $inReplyToStatusId = null, $extraAttributes = []) : Response`
- `statusesUserTimeline(array $options = []) : Response`
- `usersLookup($id, array $params = []) : Response`
- `usersSearch(string $query, array $options = []) : Response`
- `usersShow($id) : Response`

Proxy Properties
----------------

[](#proxy-properties)

The following proxy properties are allowed:

- account
- application
- blocks
- directmessages
- favorites
- followers
- friends
- friendships
- lists
- search
- statuses
- users

In each case, you can identify available methods for the proxy by comparing the proxy name to the above list of methods. As an example, the `users` proxy allows the following:

```
$twitter->users->lookup($id, array $params = []);
$twitter->users->search(string $query, array $options = []);
$twitter->users->show($id);
```

Direct access
-------------

[](#direct-access)

The Twitter API has dozens of endpoints, some more popular and/or useful than others. As such, we are only providing a subset of what is available.

However, we allow you to access any endpoint via either the `get()` or `post()`methods, which have the following signatures:

```
public function get(string $path, array $query = []) : Response;
public function post(string $path, $data = null) : Response;
```

In each case, the `$path` is the API endpoint as detailed in the Twitter API documentation, minus any `.json` suffix, and the method name corresponds to whether the request happens via HTTP GET or POST.

For HTTP GET requests, the `$query` argument provides any query string parameters you want to pass for that endpoint. As an example, if you were requesting `statuses/home_timeline`, you might pass `count` or `since_id`.

For HTTP POST requests, the `$data` argument can be one of:

- An associative array of data.
- A serializable object of data.
- A string representing the raw payload.

The data to provide will vary based on the endpoint.

Media uploads
-------------

[](#media-uploads)

Since version 3.0, we have supported media uploads via the classes `ZendService\Twitter\Media`, `Image`, and `Video`. In each case, you will instantiate the appropriate class with the local filesystem path of the image to upload and the media type, followed by calling `upload()` with a properly configured HTTP client. The response will contain a `media_id` property, which you can then provide via the `media_ids` parameter when posting a status:

```
$image = new Image('data/logo.png', 'image/png');
$response = $image->upload($twitter->getHttpClient());

$twitter->statusUpdate(
    'A post with an image',
    null,
    ['media_ids' => [$response->media_id]]
);
```

When providing media for direct messages, you must provide additional flags to the media class's constructor:

- A flag indicating it is for a direct message
- A flag indicating whether or not the uploaded media may be shared/re-used in other direct messages.

```
$image = new Image(
    'data/logo.png',
    'image/png',
    $forDirectMessage = true,
    $shared = false
);
$upload = $image->upload($twitter->getHttpClient());
```

Unlike non-DM media uploads, the identifier will be in the `id_str` parameter of the returned upload instance; use that as a `media_id` in your DM:

```
$twitter->directmessagesEventsNew(
    $user,
    $message,
    ['media_id' => $upload->id_str]
);
```

Note: direct messages only support a single attachment.

Rate limiting
-------------

[](#rate-limiting)

As of version 3.0, we now provide introspection of Twitter's rate limit headers, allowing you to act on them:

```
$response = $twitter->statusUpdate('A post');
$rateLimit = $response->getRateLimit();
if ($rateLimit->remaining === 0) {
    // Time to back off!
    sleep($rateLimit->reset); // seconds left until reset
}
```

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 53% 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 ~149 days

Recently: every ~135 days

Total

17

Last Release

2693d ago

Major Versions

2.1.0 → 3.0.02017-08-15

PHP version history (2 changes)2.0.0PHP &gt;=5.3.3

3.0.0PHP ^7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/296074?v=4)[Zend Framework](/maintainers/zendframework)[@zendframework](https://github.com/zendframework)

---

Top Contributors

[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (143 commits)")[![Maks3w](https://avatars.githubusercontent.com/u/1301698?v=4)](https://github.com/Maks3w "Maks3w (45 commits)")[![calevans](https://avatars.githubusercontent.com/u/426938?v=4)](https://github.com/calevans "calevans (22 commits)")[![blanchonvincent](https://avatars.githubusercontent.com/u/1580512?v=4)](https://github.com/blanchonvincent "blanchonvincent (14 commits)")[![ralphschindler](https://avatars.githubusercontent.com/u/76674?v=4)](https://github.com/ralphschindler "ralphschindler (6 commits)")[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (5 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (4 commits)")[![DASPRiD](https://avatars.githubusercontent.com/u/233300?v=4)](https://github.com/DASPRiD "DASPRiD (4 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (4 commits)")[![brandung-gs](https://avatars.githubusercontent.com/u/97840058?v=4)](https://github.com/brandung-gs "brandung-gs (3 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (2 commits)")[![mlamp](https://avatars.githubusercontent.com/u/2169037?v=4)](https://github.com/mlamp "mlamp (2 commits)")[![thomasweidner](https://avatars.githubusercontent.com/u/424710?v=4)](https://github.com/thomasweidner "thomasweidner (2 commits)")[![lorenzoferrarajr](https://avatars.githubusercontent.com/u/1518144?v=4)](https://github.com/lorenzoferrarajr "lorenzoferrarajr (2 commits)")[![odino](https://avatars.githubusercontent.com/u/328420?v=4)](https://github.com/odino "odino (1 commits)")[![postalservice14](https://avatars.githubusercontent.com/u/46067?v=4)](https://github.com/postalservice14 "postalservice14 (1 commits)")[![DevDavido](https://avatars.githubusercontent.com/u/997605?v=4)](https://github.com/DevDavido "DevDavido (1 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (1 commits)")[![billkarwin](https://avatars.githubusercontent.com/u/59268?v=4)](https://github.com/billkarwin "billkarwin (1 commits)")[![SocalNick](https://avatars.githubusercontent.com/u/294123?v=4)](https://github.com/SocalNick "SocalNick (1 commits)")

---

Tags

phptwittertwitter-apizendframeworktwitterZendFrameworkzf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zendframework-zendservice-twitter/health.svg)

```
[![Health](https://phpackages.com/badges/zendframework-zendservice-twitter/health.svg)](https://phpackages.com/packages/zendframework-zendservice-twitter)
```

PHPackages © 2026

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