Search code examples
jqueryajaxjsonapijustin.tv

Justin TV API - Jquery / JSON


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.


Solution

  • 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);
    });