如何獲取用戶的新聞提要,就像他們在Twitter上看到的一樣。我正在使用用戶登錄到Twitter的網站上工作,並且該頁面向他們顯示了他們的Feed,而不需要他們去推特。如何獲取推特新聞Feed
-2
A
回答
0
這應該有所幫助,只需更改用戶名,它會以json格式爲您提供Twitter提要。
<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?callback=twitterCallback2&count=2&include_rts=true&screen_name=TWITTERUSERNAME"></script>
+0
API v1將被棄用。最好更新到1.1的URL。 – Ragnarokkr
0
1
請參見本snipet例如:
<?php
$fname = "../tmp/twitter.cache.html";
// Sistema de cache - tentando recuperar
if (file_exists($fname)) {
if (time() - filemtime($fname) < 240) {
echo file_get_contents($fname);
exit;
}
}
ob_start();
?>
<style>
ul li {
list-style:none;
}
</style>
<?php
$url = 'https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=unilogica&count=35';
$xml = @simplexml_load_file($url);
$twitter = @json_decode(file_get_contents("http://api.twitter.com/1/users/show.json?screen_name=unilogica"));
$avatar = $twitter->profile_image_url;
if (!isset($xml->channel->item)) {
echo "<center>Oops, Twitter instavel...</center>";
exit;
}
foreach(@$xml->channel->item as $node){
$node->title = substr($node->title, 10);
$offset = strpos($node->title, ' RT @');
if ($offset !== false) {
$screen_name = substr($node->title, $offset+5, strpos($node->title, ':', 2) - $pos - 5);
$twitter = json_decode(file_get_contents("http://api.twitter.com/1/users/show.json?screen_name=$screen_name"));
$node->title = str_replace(" RT @$screen_name:", "<img width=\"32\" height=\"32\" align=\"left\" src=\"{$twitter->profile_image_url}\">", $node->title);
} else {
$node->title = "<img width=\"32\" height=\"32\" align=\"left\" src=\"{$avatar}\"> ".$node->title;
}
echo '<ul>';
printf('<li><div class="twitter-msg-container"><a href="%s" style="color:#069; font-family: arial, verdana, helvetica, sans-serif;" target="_blank">%s</a></div></li>',
$node->link,
$node->title
);
echo '</ul>';
}
$buffer = ob_get_clean();
@file_put_contents($fname, $buffer);
echo $buffer;
相關問題
- 1. 獲取Facebook新聞Feed iOS?
- 2. Facebooker和圖形API,獲取新聞Feed
- 3. 從facebook新聞Feed獲取視頻
- 4. 如何使用Facebook圖形API獲取新聞Feed?
- 5. 如何在發佈的新聞Feed上獲取時間?
- 6. 如何從GOOGLE AJAX Feed API獲取新聞項目的描述
- 7. Facebook如何將數據推送到新聞Feed?
- 8. 如何使用FQL返回新聞Feed
- 9. 如何使用api獲取新聞Feed究竟如何出現在Facebook首頁新聞源中
- 10. Firebase Swift分頁新聞Feed
- 11. 使用Ruby和Nokogiri從RDF Feed獲取新聞?
- 12. 如何獲取Google新聞RSS Feed中的相關文章羣集?
- 13. 如何獲取牆上或新聞Feed中每個條目的圖片?
- 14. RSS新聞推送
- 15. 優化新聞獲取
- 16. 在android中獲取新聞
- 17. 將類別特定新聞Feed嵌入到我的網站上?
- 18. 如何獲取utf8 rss feed?
- 19. 滾動新聞Feed重疊div
- 20. mySQL php查詢 - 新聞/好友Feed
- 21. 新聞Feed中缺少信息
- 22. 活動流的新聞Feed幫助
- 23. 使用Parse.com查詢製作新聞Feed
- 24. Bing分析元素新聞Feed
- 25. 新聞Feed的反應體系結構
- 26. 在Facebook上播放視頻新聞Feed
- 27. 發佈swf到新聞源(「Feed Gaming」)
- 28. 創建新聞Feed的概念
- 29. 使用JavaScript獲取推特更新
- 30. 如何在Google App Engine上建模社交新聞Feed
我猜你正在尋找這個https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline – Ragnarokkr
你看了什麼Twitter的API? https://dev.twitter.com/docs/api/1/get/statuses/user_timeline – epascarello
對於剪切和粘貼小部件:twitter.com/about/resources/widgets – Mooseman