作成された地理対応ツイートを地図上にプロットするダッシュボードを作成しています。大きな問題は、私が実際にライブであるとシミュレートするために、新しいリクエストが毎秒行われることです.
Twitter の API 制限により、REST API 呼び出しは unAuth/OAth で 1 時間あたり 150/350 に制限されているため (それぞれ)、毎秒呼び出しを行うことはできません。おそらく、更新の遅延を受け入れる必要がありますが、回避策があるかどうかに興味があります.
ユーザーがつぶやくとすぐに地図上に点を表示する真のライブ フィードを作成する方法はありますか?
大まかな参照用のコードの一部を次に示します。
// url is set above with the search query
function firstQuery(terms, oldestTweet, page, pic) {
getLimiter++;
var encodedTerms = encodeURIComponent(terms);
$.getJSON(url + '&page=' + page + '&max_id=' + oldestTweet + '&include_entities=1&result_type=recent&rpp=100&callback=?', function(tweets) {
if ($(tweets.results).length) {
if (storedLatestTweet < tweets.results[0].id) {
storedLatestTweet = tweets.results[0].id;
}
page++;
tweetCount = tweetCount + tweets.results.length;
storedOldestTweet = tweets.results[tweets.results.length - 1].id;
harvest(tweets, pic);
firstQuery(terms, oldestTweet, page, pic);
} else {
// continue to loop if more need to be plotted with the oldest tweet id known
if (getLimiter < 65 && tweetNumber < 10) {
page = 1;
firstQuery(terms, storedOldestTweet, page, pic);
}
return latestLoop(); // loops the request
}
});
}
function latestLoop() {
latest(terms, storedLatestTweet, page, pic);
// use queryLoop so that the timeout can be killed on new search
queryLoop = setTimeout(function() {
latestLoop();
}, 1000); // the loop rate of the request...1 second isn't gonna work
}