我正在尝试从我的应用程序获取来自英国的“Bristol”特定位置的Twitter趋势。如何从twitter获取关于特定位置的趋势
问题是,现在我们可以获得twitter API中提及的仅适用于国家和美国的一些城市的趋势。但我只是想知道像
http://trendsmap.com/local/gb/bristol
该网站是如何得到的趋势大多数国家和城市,即使他们没有在Twitter的趋势API上市。
搞清楚这个
问候请帮帮忙, 萨库马尔
我正在尝试从我的应用程序获取来自英国的“Bristol”特定位置的Twitter趋势。如何从twitter获取关于特定位置的趋势
问题是,现在我们可以获得twitter API中提及的仅适用于国家和美国的一些城市的趋势。但我只是想知道像
http://trendsmap.com/local/gb/bristol
该网站是如何得到的趋势大多数国家和城市,即使他们没有在Twitter的趋势API上市。
搞清楚这个
问候请帮帮忙, 萨库马尔
我尝试使用WOEID的布里斯托尔(布里斯托尔WOEID = 13963)使用下面,但它给页面没有找到错误 http://api.twitter.com/1/trends/13963.xml – JavaGeek 2010-12-11 05:41:59
我把一个漂亮的JS提琴应该回答你所有的问题,当谈到与Twitter的API。该Web应用抓取热门地区,并允许您深入探究趋势主题,然后查看其中的推文。
我还包括一个标准的Twitter搜索提交框,所以以一种奇怪的方式,这是一个准系统Tweetdeck客户端,供您检查。另外,为了推动新的Jquery库的适应性,我使用了1.91新的live.bind click事件语法的实用工具。
享受
http://jsfiddle.net/jdrefahl/5M3Gn/
function searchTwitter(query) {
$.ajax({
url: 'http://search.twitter.com/search.json?' + jQuery.param(query),
dataType: 'jsonp',
success: function (data) {
var tweets = $('#tweets');
tweets.html('');
for (res in data['results']) {
tweets.append('<div>' + data['results'][res]['from_user'] + ' wrote: <p>' + data['results'][res]['text'] + '</p></div><br />');
}
}
});
}
$(文件)。就绪(函数(){
function getTrendsByID(id) {
$.ajax({
url: 'http://api.twitter.com/1/trends/' + id + '.json',
dataType: 'jsonp',
success: function (data) {
$.each(data[0].trends, function (i) {
});
}
});
};
function getLocales() {
$.ajax({
url: 'https://api.twitter.com/1/trends/available.json',
dataType: 'jsonp',
success: function (data) {
var locales = $('ul#locales');
locales.html('');
$.each(data, function (i) {
localeID[i] = data[i].woeid;
$('ul#locales').append('<li>' + data[i].name + '</li>');
});
}
});
};
function getTrends(id) {
$.ajax({
url: 'https://api.twitter.com/1/trends/' + id + '.json',
dataType: 'jsonp',
success: function (data) {
var trends = $('ul#currentTrends');
trends.html('');
$.each(data[0].trends, function (i) {
$('ul#currentTrends').append('<li>' + data[0].trends[i].name + '</li>');
});
}
});
};
// Event Handlers
$(document).on("click", "#locales li", function() {
var $this = $(this);
var localesHdr = $('#currentTrendsCont h3');
var tweets = $('#tweets');
var trendsHdr = $('#tweetsCont h3');
trendsHdr.html('');
tweets.html('');
localesHdr.html('');
$('#currentTrendsCont h3').html($this.text());
getTrends(localeID[$this.index()]);
});
$(document).on("click", "#currentTrends li", function() {
var $this = $(this);
var trendsHdr = $('#tweetsCont h3');
trendsHdr.html('');
$('#tweetsCont h3').html($this.text());
var params = {
q: $this.text(),
rpp: 10
};
searchTwitter(params);
});
$('#submit').click(function() {
var trendsHdr = $('#tweetsCont h3');
var trends = $('#currentTrends');
var local = $('#currentTrendsCont h3');
local.html('');
trendsHdr.html('');
trends.html('');
$('#tweetsCont h3').html('search query: '+$('#query').val());
var params = {
q: $('#query').val(),
rpp: 10
};
searchTwitter(params);
});
// Globals
var localeID = new Array();
// Init!
getLocales();
});
感叹............ – Yehonatan 2010-12-09 11:46:07
检查这个答案︰http://stackoverflow.com/questions/10616017/getting-top-twitter-trends-by-country/17107785#17107785 – trante 2013-06-15 11:35:28