ttools/ttools

A Twitter API wrapper library

3.1 2015-07-12 14:32 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License

ttools

TTools (Twitter Tools) Library aims to make life easier for twitter app developers, providing a simple workflow for authentication, while maintaining a high level of flexibility for various types of applications.

TTools is specially handy for simple "static" apps that don't require user authentication (because they use static keys), like Twitter bots.

For more info and detailed installation instructions, check the documentation.

Installation via Composer

$ composer require ttools/ttools

Or, add the requirement directly to your composer.json file:

{
    "require": {
            "ttools/ttools": "~2.1"
    }
}

Basic Usage

Static Apps

<?php
$config = array(
    'consumer_key'        => 'APP_CONSUMER_KEY',
    'consumer_secret'     => 'APP_CONSUMER_SECRET',
    'access_token'        => 'USER_ACCESS_TOKEN',
    'access_token_secret' => 'USER_ACCESS_TOKEN_SECRET',
);

$app = new \TTools\App($config);
$user = $app->getCredentials();

echo "This is the static user:<br><pre>";
print_r($user);
echo "</pre>";

Multi User Apps (with authentication)

<?php
$config = array(
    'consumer_key'  => 'APP_CONSUMER_KEY',
    'consumer_secret' => 'APP_CONSUMER_SECRET'
);

$app = new \TTools\App($config);

if ($app->isLogged()) {
    $user = $app->getCurrentUser();

    echo "This is the logged user:<br><pre>";
    print_r($user);
    echo "</pre>";

} else {
    $login_url = $app->getLoginUrl();
    echo 'Please log in: <a href="'. $login_url . '">' . $login_url . '</a>';
}