joshmoody / twitter-consumer
Twitter 仅认证 API 消费者
dev-master
2014-02-05 02:27 UTC
Requires
- php: >=5.3.3
- kriswallsmith/buzz: >=0.10
Requires (Dev)
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: 1.*
This package is auto-updated.
Last update: 2024-08-29 03:55:35 UTC
README
Twitter 消费者
从 Twitter REST API 1.1 版本开始,所有请求都需要 OAuth。
2013 年 3 月 11 日,Twitter 发布了仅应用认证,允许代表一个应用程序进行请求,而不是代表一个特定的用户。
此库实现了针对公共资源(如用户时间线)的新认证。
有关更多信息,请参阅 https://dev.twitter.com/docs/auth/application-only-auth。
安装
此库可以通过 composer 安装。
"require": {
"joshmoody/twitter-consumer": "dev-master"
},
使用
// Get new instance of the twitter consumer.
$consumer = new joshmoody\Twitter\Consumer('your-consumer-key', 'your-consumer-secret);
// Fetch a joshmoody\Twitter\Response object
$response = $consumer->request('statuses/user_timeline.json?screen_name=joshmoody');
// Get the result as a stdclass object
$timeline = $timeline->result();
// ...or as RSS
$rss = $timeline->rss(array('feed_title'=>'Tweets from @username', 'feed_url' => 'http://yourdomain.com/path/to/rss/feed', 'feed_description'=>'My Tweets'));
// ...or as JSON encoded
$json = $timeline->json();
待办事项
- 添加展开自动缩短 URL 的选项
- 添加可选的源缓存
单元测试。
此包使用 PHPUnit 进行单元测试。要运行单元测试,您需要使用 Composer 安装依赖项。
php composer.phar install --dev.
然后使用 vendor/bin/phpunit
运行测试。