PHPackages                             pingpong/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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. pingpong/twitter

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

pingpong/twitter
================

Twitter OAuth for Laravel

v2.1.0(10y ago)3045.9k10[2 issues](https://github.com/pingpong-labs/twitter/issues)BSD-3-ClausePHPPHP &gt;=5.5.9

Since Aug 4Pushed 10y ago6 watchersCompare

[ Source](https://github.com/pingpong-labs/twitter)[ Packagist](https://packagist.org/packages/pingpong/twitter)[ RSS](/packages/pingpong-twitter/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (8)Versions (17)Used By (0)

Twitter OAuth for Laravel
=========================

[](#twitter-oauth-for-laravel)

[![Build Status](https://camo.githubusercontent.com/bdc94f7733267f7b3b6c3b6f37d9bcf666aab261013e7afd3f8f358a58af96c0/68747470733a2f2f7472617669732d63692e6f72672f70696e67706f6e672d6c6162732f747769747465722e737667)](https://travis-ci.org/pingpong-labs/twitter)[![Latest Stable Version](https://camo.githubusercontent.com/3c71a93203a85b4fe23c6e5eaa28f792951e31391beefcc2b062f9786ac6061e/68747470733a2f2f706f7365722e707567782e6f72672f70696e67706f6e672f747769747465722f762f737461626c652e737667)](https://packagist.org/packages/pingpong/twitter)[![Total Downloads](https://camo.githubusercontent.com/7af5dfe0e8a4cc24c7eb999c57a05069cadad96feef92327c1c1778f50c38359/68747470733a2f2f706f7365722e707567782e6f72672f70696e67706f6e672f747769747465722f646f776e6c6f6164732e737667)](https://packagist.org/packages/pingpong/twitter)[![Latest Unstable Version](https://camo.githubusercontent.com/8547fceb34bb1492aad85e7bed210fad612ae4a6542223d80fe3a6fe8e0d95cc/68747470733a2f2f706f7365722e707567782e6f72672f70696e67706f6e672f747769747465722f762f756e737461626c652e737667)](https://packagist.org/packages/pingpong/twitter)[![License](https://camo.githubusercontent.com/945f63b7ca3bfcdfa5353b9d240aae25d132a8bcc77b98092b6d5a41a020e78e/68747470733a2f2f706f7365722e707567782e6f72672f70696e67706f6e672f747769747465722f6c6963656e73652e737667)](https://packagist.org/packages/pingpong/twitter)[![HHVM Status](https://camo.githubusercontent.com/c3798d142bbf4f26138ca0c907fb74fa59657dce2b27d689c8c853712a86c196/687474703a2f2f6868766d2e683463632e64652f62616467652f70696e67706f6e672f747769747465722e737667)](http://hhvm.h4cc.de/package/pingpong/twitter)

### Server Requirements

[](#server-requirements)

```
Require PHP 5.4+ or higher.

```

### Installation

[](#installation)

> For Laravel 4.\* please use version `1.*`.

Open your composer.json file, and add the new required package.

```
  "pingpong/twitter": "~2"

```

Next, open a terminal and run.

```
  composer update

```

After the composer updated. Add new service provider in app/config/app.php.

```
	'Pingpong\Twitter\TwitterServiceProvider'
```

Next, Add new alias.

```
    'Twitter'           => 'Pingpong\Twitter\Facades\Twitter',
```

Next, open a terminal and run.

```
  php artisan vendor:publish --provider="Pingpong\Twitter\TwitterServiceProvider"

```

Done.

### Configuration File

[](#configuration-file)

```
return array(
	'consumer_key'		=>	'',
	'consumer_secret'	=>  '',

	'oauth_token'		=>	null,
	'oauth_token_secret'=>  null,

	'bearer_token'		=>	null,

	'callback_url'		=>  url('twitter/callback'),
    'fallback_url'      =>  url('/')
);
```

### Usage

[](#usage)

Authorize the user.

```
Twitter::authorize();
```

Authenticate the user.

```
Twitter::authenticate();
```

You can also override the callback url when authorize or authenticate the user.

```
$callbackUrl = url('twitter/getcallback');

Twitter::authorize($callbackUrl);

Twitter::authenticate($callbackUrl);
```

Get callback after authorize or authenticate the user.

```
Twitter::getCallback();

// or using `callback` method

Twitter::callback();
```

Get account verify credentials.

```
Twitter::getAccountVerifyCredentials();

// you can also specify what parameters want you use

$parameters = array();

Twitter::getAccountVerifyCredentials($parameters);

// or using `getCredentials` method

Twitter::getCredentials($parameters);
```

Global API call.

```
Twitter::api($method, $path, $parameters, $multipart, $appOnlyAuth);

Twitter::api('GET', '/path');

Twitter::api('POST', '/path', $parameters);

Twitter::api('PUT', '/path', $parameters);

Twitter::api('PATCH', '/path', $parameters);

Twitter::api('DELETE', '/path/to', $parameters);
```

Helper method for call Twitter API.

GET Request

```
Twitter::get('/path', $parameters);
```

POST Request

```
Twitter::post('/path', $parameters);
```

PUT Request

```
Twitter::put('/path', $parameters);
```

PATCH Request

```
Twitter::patch('/me', $parameters);
```

DELETE Request

```
Twitter::delete('/me', $parameters);
```

Set return format.

```
Twitter::format('json');

Twitter::format('array');

Twitter::format('object');
```

Enable and disable curl.

```
Twitter::enableCurl();

Twitter::disableCurl();
```

Set connection and request timeout.

```
Twitter::setConnectionTimeout(2000);

Twitter::setTimeout(500);
```

Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token with xAuth.

```
Twitter::xAuth($username, $password);
```

Set token.

```
Twitter::setToken($oauthToken, $oauthTokenSecret);
```

Get bearer token.

```
$token = Twitter::getBearerToken();
```

Set bearer token.

```
Twitter::setBearerToken($token);
```

### Example

[](#example)

Authenticate the user.

```
Route::get('twitter/authenticate', function()
{
    return Twitter::authenticate();
});
```

Authorize the user.

```
Route::get('twitter/authorize', function()
{
    return Twitter::authorize();
});
```

Get twitter callback.

```
Route::get('twitter/callback', function()
{
    try
    {
        $callback = Twitter::getCallback();

        dd($callback);
    }
    catch(Pingpong\Twitter\Exceptions\TwitterApiException $e)
    {
        var_dump($e->getMessage());
        var_dump($e->getResponse());
    }
});
```

Logout the user.

```
Route::get('twitter/logout', function()
{
    Twitter::logout();

    return Redirect::home();
});
```

Post tweet.

```
Route::get('twitter/tweet', function()
{
    try
    {
        $status = 'Hello world!';

        $response = Twitter::tweet($status);

        dd($response);
    }
    catch(Pingpong\Twitter\Exceptions\TwitterApiException $e)
    {
        var_dump($e->getMessage());
        var_dump($e->getResponse());
    }
});
```

Upload media.

```
Route::get('twitter/upload', function()
{
    try
    {
        $status = 'Hello world!';
        $media  = '/path/to/your-media.ext';

        $response = Twitter::upload($status, $media);

        dd($response);
    }
    catch(Pingpong\Twitter\Exceptions\TwitterApiException $e)
    {
        var_dump($e->getMessage());
        var_dump($e->getResponse());
    }
});
```

### REST API v1.1 Resources

[](#rest-api-v11-resources)

#### Timelines

[](#timelines)

Timelines are collections of Tweets, ordered with the most recent first.

###### GET statuses/mentions\_timeline

[](#get-statusesmentions_timeline)

Returns the 20 most recent mentions (tweets containing a users's @screen\_name) for the authenticating user.

```
Twitter::getStatusesMentionsTimeline($parameters, $multipart, $appOnlyAuth);
```

###### GET statuses/user\_timeline

[](#get-statusesuser_timeline)

Returns a collection of the most recent Tweets posted by the user indicated by the screen\_name or user\_id parameters.

```
Twitter::getStatusesUserTimeline($parameters, $multipart, $appOnlyAuth);
```

###### GET statuses/home\_timeline

[](#get-statuseshome_timeline)

Returns a collection of the most recent Tweets and retweets posted by the authenticating user and the users they follow.

```
Twitter::getStatusesHomeTimeline($parameters, $multipart, $appOnlyAuth);
```

###### GET statuses/retweet\_of\_me

[](#get-statusesretweet_of_me)

Returns the most recent tweets authored by the authenticating user that have been retweeted by others.

```
Twitter::getStatusesRetweetsOfMe($parameters, $multipart, $appOnlyAuth);
```

#### Tweets

[](#tweets)

Tweets are the atomic building blocks of Twitter, 140-character status updates with additional associated metadata.

###### GET statuses/retweets/:id

[](#get-statusesretweetsid)

Returns a collection of the 100 most recent retweets of the tweet specified by the id parameter.

```
Twitter::getStatusesRetweets($id, $parameters, $multipart, $appOnlyAuth);
```

###### GET statuses/show/:id

[](#get-statusesshowid)

Returns a single Tweet, specified by the id parameter.

```
Twitter::getStatusesShow($id, $parameters, $multipart, $appOnlyAuth);
```

###### POST statuses/destroy/:id

[](#post-statusesdestroyid)

Destroys the status specified by the required ID parameter.

```
Twitter::postStatusesDestroy($id, $parameters, $multipart, $appOnlyAuth);
```

###### POST statuses/update

[](#post-statusesupdate)

Updates the authenticating user's current status, also known as tweeting.

```
Twitter::postStatusesUpdate($parameters, $multipart, $appOnlyAuth);
```

###### POST statuses/retweet/:id

[](#post-statusesretweetid)

Retweets a tweet.

```
Twitter::postStatusesRetweet($id, $parameters, $multipart, $appOnlyAuth);
```

###### POST statuses/update\_with\_media

[](#post-statusesupdate_with_media)

Updates the authenticating user's current status and attaches media for upload.

```
Twitter::postStatusesUpdateWithMedia($parameters, $appOnlyAuth);
```

###### GET statuses/oembed

[](#get-statusesoembed)

Returns information allowing the creation of an embedded representation of a Tweet on third party sites.

```
Twitter::getStatusesOembed($parameters, $multipart, $appOnlyAuth);
```

###### GET statuses/retweeters/ids

[](#get-statusesretweetersids)

Returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter.

```
Twitter::getStatusesRetweetersIds($parameters, $multipart, $appOnlyAuth);
```

#### Search

[](#search)

Find relevant Tweets based on queries performed by your users.

###### GET search/tweets

[](#get-searchtweets)

Returns a collection of relevant Tweets matching a specified query.

```
Twitter::getSearchTweets($parameters, $multipart, $appOnlyAuth);
```

###### Direct Messages

[](#direct-messages)

Direct Messages are short, non-public messages sent between two users.

```
Twitter::getSearchTweets($parameters, $multipart, $appOnlyAuth);
```

###### GET direct\_messages

[](#get-direct_messages)

Returns the 20 most recent direct messages sent to the authenticating user.

```
Twitter::getDirectMessages($parameters, $multipart, $appOnlyAuth);
```

###### GET direct\_messages/sent

[](#get-direct_messagessent)

Returns the 20 most recent direct messages sent by the authenticating user.

```
Twitter::getDirectMessagesSent($parameters, $multipart, $appOnlyAuth);
```

###### GET direct\_messages/show

[](#get-direct_messagesshow)

Returns a single direct message, specified by an id parameter.

```
Twitter::getDirectMessagesShow($parameters, $multipart, $appOnlyAuth);
```

###### POST direct\_messages/destroy

[](#post-direct_messagesdestroy)

Destroys the direct message specified in the required ID parameter.

```
Twitter::postDirectMessagesDestroy($parameters, $multipart, $appOnlyAuth);
```

###### POST direct\_messages/new

[](#post-direct_messagesnew)

Sends a new direct message to the specified user from the authenticating user.

```
Twitter::postDirectMessagesNew($parameters, $multipart, $appOnlyAuth);
```

#### Favorites

[](#favorites)

Users favorite tweets to give recognition to awesome tweets, to curate the best of Twitter, to save for reading later, and a variety of other reasons. Likewise, developers make use of "favs" in many different ways.

###### GET favorites/list

[](#get-favoriteslist)

Returns the 20 most recent Tweets favorited by the authenticating or specified user.

```
Twitter::getFavoritesList($parameters, $multipart, $appOnlyAuth);
```

###### POST favorites/destroy

[](#post-favoritesdestroy)

Un-favorites the status specified in the ID parameter as the authenticating user.

```
Twitter::postFavoritesDestroy($parameters, $multipart, $appOnlyAuth);
```

###### POST favorites/create

[](#post-favoritescreate)

Favorites the status specified in the ID parameter as the authenticating user.

```
Twitter::postFavoritesCreate($parameters, $multipart, $appOnlyAuth);
```

**NOTE: Not all functions and Facade APIs documented**

### License

[](#license)

This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 70.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 ~45 days

Recently: every ~80 days

Total

14

Last Release

3714d ago

Major Versions

1.0.4 → 2.0.02015-04-27

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

1.0.2-BetaPHP &gt;=5.4.0

2.1.x-devPHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/5221291be74d1e0ddef6931aa833f02a106df5b972431926321bf4f12d16b62b?d=identicon)[gravitano](/maintainers/gravitano)

---

Top Contributors

[![gravitano](https://avatars.githubusercontent.com/u/5087538?v=4)](https://github.com/gravitano "gravitano (51 commits)")[![mjmarianetti](https://avatars.githubusercontent.com/u/6825791?v=4)](https://github.com/mjmarianetti "mjmarianetti (13 commits)")[![jramcast](https://avatars.githubusercontent.com/u/675470?v=4)](https://github.com/jramcast "jramcast (6 commits)")[![AlexLombry](https://avatars.githubusercontent.com/u/1451210?v=4)](https://github.com/AlexLombry "AlexLombry (1 commits)")[![KIVagant](https://avatars.githubusercontent.com/u/517501?v=4)](https://github.com/KIVagant "KIVagant (1 commits)")

---

Tags

laraveloauthtwitterpingpong

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[kovah/laravel-socialite-oidc

OpenID Connect OAuth2 Provider for Laravel Socialite

2073.7k](/packages/kovah-laravel-socialite-oidc)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

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