2017 © Pedro Peláez
 

library twitter

Twitter OAuth for Laravel

image

pingpong/twitter

Twitter OAuth for Laravel

  • Sunday, March 13, 2016
  • by gravitano
  • Repository
  • 6 Watchers
  • 29 Stars
  • 4,353 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 2 Open issues
  • 17 Versions
  • 12 % Grown

The README.md

Twitter OAuth for Laravel

Build Status Latest Stable Version Total Downloads Latest Unstable Version License HHVM Status, (*1)

Server Requirements

Require PHP 5.4+ or higher.

Installation

For Laravel 4.* please use version 1.*., (*2)

Open your composer.json file, and add the new required package., (*3)

  "pingpong/twitter": "~2" 

Next, open a terminal and run., (*4)

  composer update 

After the composer updated. Add new service provider in app/config/app.php., (*5)

    'Pingpong\Twitter\TwitterServiceProvider'

Next, Add new alias., (*6)

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

Next, open a terminal and run., (*7)

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

Done., (*8)

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

Authorize the user., (*9)

Twitter::authorize();

Authenticate the user., (*10)

Twitter::authenticate();

You can also override the callback url when authorize or authenticate the user., (*11)

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

Twitter::authorize($callbackUrl);

Twitter::authenticate($callbackUrl);

Get callback after authorize or authenticate the user., (*12)

Twitter::getCallback();

// or using `callback` method

Twitter::callback();

Get account verify credentials., (*13)

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., (*14)

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., (*15)

GET Request, (*16)

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

POST Request, (*17)

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

PUT Request, (*18)

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

PATCH Request, (*19)

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

DELETE Request, (*20)

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

Set return format., (*21)

Twitter::format('json');

Twitter::format('array');

Twitter::format('object');

Enable and disable curl., (*22)

Twitter::enableCurl();

Twitter::disableCurl();

Set connection and request timeout., (*23)

Twitter::setConnectionTimeout(2000);

Twitter::setTimeout(500);

Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token with xAuth., (*24)

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

Set token., (*25)

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

Get bearer token., (*26)

$token = Twitter::getBearerToken();

Set bearer token., (*27)

Twitter::setBearerToken($token);

Example

Authenticate the user., (*28)

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

Authorize the user., (*29)

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

Get twitter callback., (*30)

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., (*31)

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

    return Redirect::home();
});

Post tweet., (*32)

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., (*33)

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

Timelines

Timelines are collections of Tweets, ordered with the most recent first., (*34)

GET statuses/mentions_timeline

Returns the 20 most recent mentions (tweets containing a users's @screen_name) for the authenticating user., (*35)

Twitter::getStatusesMentionsTimeline($parameters, $multipart, $appOnlyAuth);
GET statuses/user_timeline

Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters., (*36)

Twitter::getStatusesUserTimeline($parameters, $multipart, $appOnlyAuth);
GET statuses/home_timeline

Returns a collection of the most recent Tweets and retweets posted by the authenticating user and the users they follow., (*37)

Twitter::getStatusesHomeTimeline($parameters, $multipart, $appOnlyAuth);
GET statuses/retweet_of_me

Returns the most recent tweets authored by the authenticating user that have been retweeted by others., (*38)

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

Tweets

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

GET statuses/retweets/:id

Returns a collection of the 100 most recent retweets of the tweet specified by the id parameter., (*40)

Twitter::getStatusesRetweets($id, $parameters, $multipart, $appOnlyAuth);
GET statuses/show/:id

Returns a single Tweet, specified by the id parameter., (*41)

Twitter::getStatusesShow($id, $parameters, $multipart, $appOnlyAuth);
POST statuses/destroy/:id

Destroys the status specified by the required ID parameter., (*42)

Twitter::postStatusesDestroy($id, $parameters, $multipart, $appOnlyAuth);
POST statuses/update

Updates the authenticating user's current status, also known as tweeting., (*43)

Twitter::postStatusesUpdate($parameters, $multipart, $appOnlyAuth);
POST statuses/retweet/:id

Retweets a tweet., (*44)

Twitter::postStatusesRetweet($id, $parameters, $multipart, $appOnlyAuth);
POST statuses/update_with_media

Updates the authenticating user's current status and attaches media for upload., (*45)

Twitter::postStatusesUpdateWithMedia($parameters, $appOnlyAuth);
GET statuses/oembed

Returns information allowing the creation of an embedded representation of a Tweet on third party sites., (*46)

Twitter::getStatusesOembed($parameters, $multipart, $appOnlyAuth);
GET statuses/retweeters/ids

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

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

Find relevant Tweets based on queries performed by your users., (*48)

GET search/tweets

Returns a collection of relevant Tweets matching a specified query., (*49)

Twitter::getSearchTweets($parameters, $multipart, $appOnlyAuth);
Direct Messages

Direct Messages are short, non-public messages sent between two users., (*50)

Twitter::getSearchTweets($parameters, $multipart, $appOnlyAuth);
GET direct_messages

Returns the 20 most recent direct messages sent to the authenticating user., (*51)

Twitter::getDirectMessages($parameters, $multipart, $appOnlyAuth);
GET direct_messages/sent

Returns the 20 most recent direct messages sent by the authenticating user., (*52)

Twitter::getDirectMessagesSent($parameters, $multipart, $appOnlyAuth);
GET direct_messages/show

Returns a single direct message, specified by an id parameter., (*53)

Twitter::getDirectMessagesShow($parameters, $multipart, $appOnlyAuth);
POST direct_messages/destroy

Destroys the direct message specified in the required ID parameter., (*54)

Twitter::postDirectMessagesDestroy($parameters, $multipart, $appOnlyAuth);
POST direct_messages/new

Sends a new direct message to the specified user from the authenticating user., (*55)

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

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., (*56)

GET favorites/list

Returns the 20 most recent Tweets favorited by the authenticating or specified user., (*57)

Twitter::getFavoritesList($parameters, $multipart, $appOnlyAuth);
POST favorites/destroy

Un-favorites the status specified in the ID parameter as the authenticating user., (*58)

Twitter::postFavoritesDestroy($parameters, $multipart, $appOnlyAuth);
POST favorites/create

Favorites the status specified in the ID parameter as the authenticating user., (*59)

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

NOTE: Not all functions and Facade APIs documented, (*60)

License

This package is open-sourced software licensed under The BSD 3-Clause License, (*61)

The Versions

13/03 2016

2.2.x-dev

2.2.9999999.9999999-dev

Twitter OAuth for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel oauth pingpong twitter

09/10 2015

2.1.x-dev

2.1.9999999.9999999-dev

Twitter OAuth for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel oauth pingpong twitter

09/10 2015
24/05 2015
24/05 2015
24/05 2015

dev-develop

dev-develop

Twitter OAuth for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel oauth pingpong twitter

27/04 2015
27/04 2015

2.0.1

2.0.1.0

Twitter OAuth for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel oauth pingpong twitter

27/04 2015
16/10 2014
05/09 2014
26/08 2014
08/08 2014

1.0.2-Beta2

1.0.2.0-beta2

Simple Twitter API for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel oauth pingpong twitter

05/08 2014

1.0.2-Beta

1.0.2.0-beta

Simple Twitter API for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel oauth pingpong twitter

05/08 2014

1.0.1

1.0.1.0

Simple Twitter OAuth for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel oauth pingpong twitter

04/08 2014

1.0.0

1.0.0.0

Simple Twitter OAuth for Laravel 4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel oauth pingpong twitter