0

I was wondering if somebody could show me an example of how to use the Justin TV API. They have this documentation and an 'example' on there along with return values (Here's the xml file) but when I try to use it I don't under stand where it defines what channel it's pulling from. If I want to pull a channels summary - I tried this:

$.getJSON("http://api.justin.tv/stream/summary?channel=dreamhacksc2", function(a){alert(a.summary);});

but I keep getting Bad Origin errors. I've been trying to find examples online but haven't found anything solid. Can somebody work up an example of pulling something from a certain channel? I could probably work off it from there.

Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186

1 Answers1

2

You don't seem to be using the right url for the summary method and JSONP. Try this one:

http://api.justin.tv/api/stream/summary.json?channel=dreamhacksc2&jsonp=?

Like this:

$.getJSON('http://api.justin.tv/api/stream/summary.json?channel=dreamhacksc2&jsonp=?', function(a) {
    alert(a.viewers_count);
});
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Oh I have a question though. If I want to get things like `channel_url`which is under `stream/list` but it's under a inner node in the xml of `channel` - how would I get that? Is it on a url base or when I alert it out on an object base? Oh I have a question though. If I want to get things like `channel_url` `stream/list` but it's under a inner node of `channel` - how would I get that? http://apiwiki.justin.tv/mediawiki/index.php/Stream/list – Howdy_McGee Jun 16 '12 at 21:34
  • 1
    Assuming you have used `http://api.justin.tv/api/stream/list.json?channel=dreamhacksc2&jsonp=?`, you could then `alert(a[0].channel.channel_url);` which should give you `http://www.justin.tv/dreamhacksc2`. – Darin Dimitrov Jun 16 '12 at 21:37