ttools / ttools
A Twitter API wrapper library
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
3.1
2015-07-12 14:32 UTC
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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>';
}