【问题标题】:Json twitter getting the coordinates and messageJson twitter 获取坐标和消息
【发布时间】:2011-09-14 07:57:20
【问题描述】:

我想从此结果中获取推文,但我无法获得正确的输入。我想要坐标。

 $.ajax(
{
    dataType: 'jsonp',
    url: 'http://search.twitter.com/search.json?&geocode=51.985103,5.89873,1mi',
    success: function (data)
    {
console.log("hoi");
        $.each(data.results, function (i, tweets)
        {

          console.log(tweets);

  for (var j = 0; j < tweets.length; j++)
{
                var tweet = tweets[j];
          console.log(tweet);
}
}

我得到这个结果:

   Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...}
   Object { from_user_id_str="23446954", location="ÜT: 51.983584,5.90971", more...}
   Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...}
   Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...}
   Object { from_user_id_str="23446954", location="ÜT: 51.983584,5.90971", more...}
   Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...}

但是当我问推文时,我得到了未定义

【问题讨论】:

    标签: javascript ajax json parsing twitter


    【解决方案1】:

    这是因为您试图在每个语句中运行 for 循环。您的 tweets 对象不是数组。您只需将 tweets 更改为 tweet,因为您是从您的 $.each() 方法中单独拉下它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      相关资源
      最近更新 更多