2010-12-09 5 views
0

내 위치에 대한 트위터 트렌드를 얻으 려하고 있습니다. 내 응용 프로그램에 대해 영국의 "Bristol"이라고 말합니다.트위터에서 특정 위치에 대한 트렌드를 얻는 방법

문제는 지금 트위터 API에서 언급 한대로 미국에서만 국가 및 일부 도시의 트렌드를 얻을 수 있다는 것입니다. 하지만 난 그냥

http://trendsmap.com/local/gb/bristol

같은 사이트들은 트위터 동향 API에 나열되지 않은 경우에도 국가와 도시의 대부분의 동향을 얻는 방법 궁금하네요.

안부를 파악하는 데 도움 주시기 바랍니다 수 쿠마

+0

한숨 ............ – Yehonatan

+0

답변 확인 : http://stackoverflow.com/questions/10616017/getting-top-twitter-trends-by-country/17107785#17107785 – trante

답변

0
+0

I 아래 브리스톨의 WOEID (Bristol WOEID = 13963)를 사용하여 시도했지만 페이지를 찾을 수 없음 오류가 발생했습니다 http://api.twitter.com/1/trends/13963.xml – JavaGeek

+0

트렌드를 저장하지 않기 때문에 브리스톨을 위해서. 나는 런던을 시험해보고 이것을 얻었다 : http://api.twitter.com/1/trends/44418.json –

+0

감사 교각. 이제 알았어. – JavaGeek

2

내가 함께가 트위터 API를 다루는에 올 때 모든 질문에 대답해야 좋은 JS 바이올린을 넣어. webapp는 트렌드 로케일을 가져와 트렌드 주제까지 드릴 다운하고 트윗을 볼 수 있습니다.

표준 트위터 검색 제출 상자도 포함되어 있습니다. 이상한 방식으로,이 트위터 클라이언트를 검토해보십시오. 또한, 새로운 Jquery 라이브러리의 적용을 위해, 1.95의 유틸리티를 사용하여 새로운 live.bind 클릭 이벤트 구문을 사용했습니다.

즐기

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 />'); 
     } 
    } 
}); 

}

$ (문서) .ready (함수() {

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(); 

});

+0

jdrefahl..its 매우 도움이되었습니다 – JavaGeek

+0

트위터에서 가장 낮은 트렌드 트윗을 얻을 수 있습니까? –

관련 문제