【发布时间】:2011-03-28 11:27:46
【问题描述】:
我正在使用 jQuery 以 json 格式检索和显示关于 2 个足球队的推文。 我目前正在输出文本和用户 ID,但我计划在谷歌地图上绘制这些推文。但首先我需要获取推文的位置。关于如何实现这一点的任何想法。
到目前为止的基本代码如下;
<script type="text/javascript">
$(document).ready(function(){
var team1, team2;
team1 = '<?php echo $_GET["team1"]; ?>';
team2 = '<?php echo $_GET["team2"]; ?>';
var url1="http://search.twitter.com/search.json?q=%23"+team1+"&callback=?";
var url2="http://search.twitter.com/search.json?q=%23"+team2+"&callback=?";
$.getJSON(
url1,function(results){ // get the tweets
var res1 = results.results[0].text;
var userID1 = results.results[0].from_user_id;
$("#last-tweet1").html(res1 + "<p>user id: " + userID1); // get the first tweet in the response and place it inside the div
});
$.getJSON(
url2,function(results){ // get the tweets
var res2 = results.results[0].text;
var userID2 = results.results[0].from_user_id;
$("#last-tweet2").html(res2 + "<p>user id: " + userID2 + "</p>"); // get the first tweet in the response and place it inside the div
});
【问题讨论】:
标签: jquery json twitter geolocation