我是Twitter Api的新手......但我在文档中读到了一些内容。
现在在我的Twitter帐户中,我有关注者,他们的推文显示在我的主页上。
我想使用PHP获取在我的主页中显示的所有推文...到目前为止我所能完成的只能获取我的推文。
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
// Make Requests
$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $url ,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false);
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);
$twitter_data = json_decode($json);
感谢,
答案 0 :(得分:1)
您可以使用home_timeline.json
代替user_timeline.json";
$url = "https://api.twitter.com/1.1/statuses/home_timeline.json";
// Make Requests
$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $url ,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false);
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);
$twitter_data = json_decode($json);
答案 1 :(得分:0)
使用Twitter小部件做这样的事情..
示例代码
<a class="twitter-timeline" href="https://twitter.com/@username" data-widget-id="438248826176933888">Tweets by @username</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
将@username替换为您的推特名称