このコードを使用して、クライアント側から Twitter ストリームに接続しています (この方法に固執する必要があります。別の方法を提供しないでください)。結果を制限して 1 つのツイートのみを表示する方法を理解しようとしています (最新の1)。現在、結果のすべてのツイートが表示されています。誰かが私を助けたい場合は、検索 URL のハッシュタグとユーザー名を編集して、自分のハッシュタグとユーザー名を挿入してください。コードは次のとおりです。
<div id="tweet_stream">
Loading #Apple tweets...
</div>
<script type="text/javascript">
jQuery(function(){
// Execute this code when the page is ready to work
// Create a Script Tag
var script=document.createElement('script');
script.type='text/javascript';
script.src= "http://search.twitter.com/search.json? q=%23HASHTAGHERE+from:USERNAMEHEREr&callback=processTheseTweets&_="+ new Date().getTime();
// Add the Script to the Body element, which will in turn load the script and run it.
$("body").append(script);
});
function processTheseTweets(jsonData){
var shtml = '';
var results = jsonData.results;
if(results){
// if there are results (it should be an array), loop through it with a jQuery function
$.each(results, function(index,value){
shtml += "<p class='title'><span class='author'>" + value.from_user + "</span>: " +
value.text + "<span class='date'>" + value.created_at + "</span></p>";
});
// Load the HTML in the #tweet_stream div
$("#tweet_stream").html( shtml );
}
}
</script>
また、リンクが表示されるように、ツイートの HTML バージョンを表示する最終結果を取得しようとしています。これらのことのいずれかを行うための助けは非常に素晴らしいでしょう!! ありがとう