开发者

Twitter API getJSON for Status ID Meta -- Response Empty!

There are some similar posts on SO about this topic but they are all dealing with search and I am trying to do something different. I have tried to apply some of the logic in answers to other questions here but w/o success. Essentially I just want users to be able to enter a status update ID into a text field, hit a button then display all meta data associated with that tweet. If I leave the callback=? part off of the URL string I get a response back but it's empty, which is obviously due to the security restrictions put in place by the Twitter API.

Here is what I am working with currently:

$.getJSON("http://www.twitter.com/statuses/show/73051651728084992.json?callback=?", 
function(Data) 
{ 
  if(Data.length)
  {
    var Content = "";
    $.each(Data,开发者_如何学Go function(i, Row)
    {
      alert("We Have Data");
      Content += Row;
    });
    $("#Result").append(Row);
  }
  else
    alert("No Result for that ID!");
})

Which comes back w/ no data, yet the request does come back w/ a 200 HTTP response. Obviously I am missing something as far as the callback goes, I am just not sure what. Just as a crude proof of concept I was going to output all of the data to the Result div and pretty it up later. Obviously first things first I need to actually have some data to work with!

What am I missing?


Remove the ?callback=? from the url and try again. You are asking Twitter's api to wrap the response in a callback ? which would result in invalid JSON. Also, whenever in doubt, load the url manually in your browser to examine whether the response is correctly formatted.

Also, change to this, since $.getJSON() returns an Object, not a string:

if (Data) {
    var Content = "";
    ..
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜