我正试图从特定用户那里获取推文,但在Code Igniter中找不到实现这一点的方法。我看到几个页面在寻找解决方案,比如:
- 如何使用php获取特定用户的最后10条推文
- https://stackoverflow.com/questions/422879/best-twitter-php-library
- http://www.jaisenmathai.com/articles/twitter-async-documentation.html
- https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION
但所有这些似乎都是为了授权,而不是为了获得推特。关于这个话题有什么帮助或建议吗?
在github:上使用此库
用于代码点火器的TwitterFetecher和读取文档
将TwitterFetcher.php
放在库文件夹中。
在你的控制器/行动加载它
public function home() {
$this->load->library('twitterfetcher');
$tweets = $this->twitterfetcher->getTweets(array(
'consumerKey' => 'yourkey',
'consumerSecret' => 'yourkey',
'accessToken' => 'yourkey',
'accessTokenSecret' => 'yourkey',
'usecache' => true,
'count' => 2, //this how many tweets to fectch
'numdays' => 30
));
$data['twiites'] = $tweets ;
$this->load->view('home/home',$data);
}
CHAW
您看过CI Sparks吗?Spark的示例构建与您询问的内容类似
那里有几个包裹,看起来他们会做你想做的事。
E.g
- mmtwitterfetcher