dev-master
9999999-devTwitter oAuth and API request library with an easy to use syntax.
MIT
The Requires
- php >=5.3.2
- ruudk/twitter-oauth *
The Development Requires
by Travis Wimer
Twitter oAuth and API request library with an easy to use syntax.
PHP class for simple Twitter oAuth token requests, authentication, and API v1.1 requests. (Built on the TwitterOAuth package), (*1)
Install with Composer by adding this to your composer.json
file:, (*2)
"require": { "traviswimer/twittering": "dev-master" }
Then run compsoser install
or php composer.phar install
, depending on your setup., (*3)
// Include Composer autoloader require_once __DIR__.'/vendor/autoload.php'; // First create initialize a Twittering object with you API key/secret $twittering = new \Twittering\Twittering(array( "api_key" => "YOUR_CONSUMER_KEY", "api_secret" => "YOUR_CONSUMER_SECRET", )); // Then the requestTokens() method can be used to redirect the user to Twitter // for authentication. The user will then be sent back to the URL of your script. // This time, when requestTokens() is called, it will detect the $_GET parameters // sent from Twitter and continue with the authorization process. $tokens = $twittering->requestTokens(); // Now that you have the tokens, you can save them to a database for future use. // To make API requests, call the authenticate() method. $apiConnection = $twittering->authenticate( $tokens ); // You are now ready to make API requests $timeline = $apiConnection->get( 'statuses/home_timeline', array('count' => '10') );
new \Twittering\Twittering( $api_auth_info, );
requestTokens( $callback_url, $redirect );
This method behaves differently if the $_GET variables oauth_token
and oauth_verifier
are set, (*4)
This will send the user to Twitter to authorize your app., (*5)
requestTokens()
will instead return the URL where you should send the user.This generate the user's long-term tokens., (*6)
No parameters are needed during this second pass. This will return an array containing the user's long-term tokens that can be stored in your database. You can also pass this array directly to the authenticate()
method., (*7)
authenticate( $tokens );
This method creates an object can interact with the Twitter API on the authenticated user's behalf., (*8)
requestTokens()
method:
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality., (*9)
Twitter oAuth and API request library with an easy to use syntax.
MIT