PHPackages                             j7mbo/twitter-api-php - 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. j7mbo/twitter-api-php

AbandonedArchivedLibrary[API Development](/categories/api)

j7mbo/twitter-api-php
=====================

Simple PHP Wrapper for Twitter API v1.1 calls

1.0.6(9y ago)1.8k9.8M—4.9%78320GNU Public LicensePHP

Since May 4Pushed 6y ago92 watchersCompare

[ Source](https://github.com/J7mbo/twitter-api-php)[ Packagist](https://packagist.org/packages/j7mbo/twitter-api-php)[ Docs](https://github.com/j7mbo/twitter-api-php)[ RSS](/packages/j7mbo-twitter-api-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (20)

twitter-api-php
===============

[](#twitter-api-php)

Simple PHP Wrapper for Twitter API v1.1 calls

[![Total Downloads](https://camo.githubusercontent.com/fb5754f24f4eb5d2eb6fa72dab5196ca7ddf5324912fe0761014c576c8eae0fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a376d626f2f747769747465722d6170692d7068702e737667)](https://packagist.org/packages/j7mbo/twitter-api-php)[![Build Status](https://camo.githubusercontent.com/f38f03f5472ab8830a45646343eaa9fba46b6753002a9cde57d54cadf78f1ef7/68747470733a2f2f7472617669732d63692e6f72672f4a376d626f2f747769747465722d6170692d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/J7mbo/twitter-api-php)[![Version](https://camo.githubusercontent.com/c26182e9a5cfba0d4515d8bcf05622ea5cc9ca2c59d510745d3cd3974059e6f4/68747470733a2f2f62616467652e667572792e696f2f67682f6a376d626f253246747769747465722d6170692d7068702e737667)](https://packagist.org/packages/j7mbo/twitter-api-php)

**[Changelog](https://github.com/J7mbo/twitter-api-php/wiki/Changelog)** || **[Examples](https://github.com/J7mbo/twitter-api-php/wiki/Twitter-API-PHP-Wiki)** || **[Wiki](https://github.com/J7mbo/twitter-api-php/wiki)**

[Instructions in StackOverflow post here](http://stackoverflow.com/questions/12916539/simplest-php-example-retrieving-user-timeline-with-twitter-api-version-1-1/15314662#15314662) with examples. This post shows you how to get your tokens and more. If you found it useful, please upvote / leave a comment! :)

The aim of this class is simple. You need to:

- Include the class in your PHP code
- [Create a twitter app on the twitter developer site](https://dev.twitter.com/apps/)
- Enable read/write access for your twitter app
- Grab your access tokens from the twitter developer site
- [Choose a twitter API URL to make the request to](https://dev.twitter.com/docs/api/1.1/)
- Choose either GET / POST (depending on the request)
- Choose the fields you want to send with the request (example: `array('screen_name' => 'usernameToBlock')`)

You really can't get much simpler than that. The above bullet points are an example of how to use the class for a POST request to block a user, and at the bottom is an example of a GET request.

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

[](#installation)

**Normally:** If you *don't* use composer, don't worry - just include TwitterAPIExchange.php in your application.

```
require_once('TwitterAPIExchange.php');
```

**Via Composer:**

```
composer require j7mbo/twitter-api-php
```

How To Use
----------

[](#how-to-use)

#### Set access tokens

[](#set-access-tokens)

```
$settings = array(
    'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN",
    'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
    'consumer_key' => "YOUR_CONSUMER_KEY",
    'consumer_secret' => "YOUR_CONSUMER_SECRET"
);
```

#### Choose URL and Request Method

[](#choose-url-and-request-method)

```
$url = 'https://api.twitter.com/1.1/blocks/create.json';
$requestMethod = 'POST';
```

#### Choose POST fields (or PUT fields if you're using PUT)

[](#choose-post-fields-or-put-fields-if-youre-using-put)

```
$postfields = array(
    'screen_name' => 'usernameToBlock',
    'skip_status' => '1'
);
```

#### Perform the request!

[](#perform-the-request)

```
$twitter = new TwitterAPIExchange($settings);
echo $twitter->buildOauth($url, $requestMethod)
    ->setPostfields($postfields)
    ->performRequest();
```

GET Request Example
-------------------

[](#get-request-example)

Set the GET field BEFORE calling buildOauth(); and everything else is the same:

```
$url = 'https://api.twitter.com/1.1/followers/ids.json';
$getfield = '?screen_name=J7mbo';
$requestMethod = 'GET';

$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
    ->buildOauth($url, $requestMethod)
    ->performRequest();
```

That is it! Really simple, works great with the 1.1 API. Thanks to @lackovic10 and @rivers on SO!

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity73

Solid adoption and visibility

Community46

Growing community involvement

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 72.8% 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 ~244 days

Total

4

Last Release

3297d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e14d34d0841dff2b3abd09f889f8c5c968fd2ccaccc00f8a6dd4d1c5ceb02f5a?d=identicon)[J7mbo](/maintainers/J7mbo)

---

Top Contributors

[![J7mbo](https://avatars.githubusercontent.com/u/2657310?v=4)](https://github.com/J7mbo "J7mbo (67 commits)")[![glenscott](https://avatars.githubusercontent.com/u/124257?v=4)](https://github.com/glenscott "glenscott (11 commits)")[![finwe](https://avatars.githubusercontent.com/u/195675?v=4)](https://github.com/finwe "finwe (3 commits)")[![ronaldpk](https://avatars.githubusercontent.com/u/1880399?v=4)](https://github.com/ronaldpk "ronaldpk (3 commits)")[![ArnaudLigny](https://avatars.githubusercontent.com/u/80580?v=4)](https://github.com/ArnaudLigny "ArnaudLigny (1 commits)")[![jezmck](https://avatars.githubusercontent.com/u/89996?v=4)](https://github.com/jezmck "jezmck (1 commits)")[![naoyukik](https://avatars.githubusercontent.com/u/10615135?v=4)](https://github.com/naoyukik "naoyukik (1 commits)")[![phansys](https://avatars.githubusercontent.com/u/1231441?v=4)](https://github.com/phansys "phansys (1 commits)")[![hugovk](https://avatars.githubusercontent.com/u/1324225?v=4)](https://github.com/hugovk "hugovk (1 commits)")[![dave1010](https://avatars.githubusercontent.com/u/50682?v=4)](https://github.com/dave1010 "dave1010 (1 commits)")[![emmetog](https://avatars.githubusercontent.com/u/1182891?v=4)](https://github.com/emmetog "emmetog (1 commits)")[![Farkie](https://avatars.githubusercontent.com/u/294921?v=4)](https://github.com/Farkie "Farkie (1 commits)")

---

Tags

phptwittertwitter-apitwitter-clienttwitter-oauthtwitterapitwitterapiexchangephpapitwitter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/j7mbo-twitter-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/j7mbo-twitter-api-php/health.svg)](https://phpackages.com/packages/j7mbo-twitter-api-php)
```

###  Alternatives

[fennb/phirehose

A PHP interface to the Twitter Streaming API.

698402.4k3](/packages/fennb-phirehose)[noweh/twitter-api-v2-php

This library provides methods for sending messages to Twitter and receiving statuses.

131225.2k1](/packages/noweh-twitter-api-v2-php)[redwebcreation/twitter-stream-api

Consume the Twitter Stream API in real-time.

3220.3k1](/packages/redwebcreation-twitter-stream-api)[owlycode/streaming-bird

A PHP client for the Twitter Streaming APIs inspired from Phirehose.

1024.6k](/packages/owlycode-streaming-bird)

PHPackages © 2026

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