php-twient is a php5.3+ twitter client library and Composer package.
- Composer package
- Use namespace for PHP 5.3+
- Support Twitter API v1.1
- Should work with/without php_curl (detects php_curl automatically)
Composer: http://getcomposer.org/
create blew composer.json on your project directory and execute composer install
/path/to/project/composer.json
{
"require": {
"makotokw/twient": "dev-master"
}
}
<?php
use Makotokw\Twient\Twitter;
$consumer_key = 'consumer key for your application';
$consumer_secret = 'consumer secret for your application';
$oauth_token = 'oauth token for your account';
$oauth_token_secret = 'oauth token secret for your account';
$twitter = new Twitter();
$twitter->oAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$statuses = $twitter->call('statuses/home_timeline');
foreach ($statuses as $status) {
echo $status['user']['name'].': '.$status['text'].PHP_EOL;
}
?>
$twitter->call('statuses/update', array('status' => 'tweet by php-twient'));
The streaming method is terminated when callback returns false.
$twitter->streaming(
'statuses/filter',
array('track' => 'Sushi,Japan'),
function ($twitter, $status) {
static $count = 0;
echo $status['user']['name'] . ':' . $status['text'] . PHP_EOL;
return ($count++ < 5);
}
);
use Makotokw\Twient\Twitter\V1dot1 as Twitter;
$twitter = new Twitter();
...
$twitter->statusesHomeTimeline(); // instead of "call('statuses/home_timeline')"
$twitter->statusesUpdate(...); // instead of "call('statuses/update', ...)"
$twitter->streamingStatusesFilter(...); // instead of "streaming('statuses/filter', ...)"
- Supported media/upload api
- Added vendor namespace
Makotokw\Twient
- No longer supported TinyURL
- PSR-4 Auto Loading
- Used https scheme for Streaming API
- Supported Twitter API v1.1
- Updated to Composer package
- Required PHP5.3+
- PSR-2 Coding Standard
- Uses the Services_JSON instead of json_decode when PHP < 5.2.0
- Fixed that OAuth part have deprecated function on PHP 5.3 or later
- Supported Trends Methods
- Updated Status Methods and User Methods
- Supported Search API.
- Supported User, Friendship and Social Graph Methods of REST API.
- Supported Streaming API.
- Changed call method returns associative arrays instead of objects.
- Added assoc flag to return associative arrays or objects.
- Initial Release
The MIT License (MIT)
See also LICENSE file