As many a Dojo user is aware, we’ve been supporting Yahoo’s forward-thinking JSON-P style endpoints for their various web services for a long time. We even have a nice RPC wrapper and simple description format for most of them. And no, you don’t have to download YUI to get at this stuff…it’s all pure Dojo. We make it easier to work with Yahoo’s services than Yahoo does.
And that now includes Yahoo Pipes. It’s cool and interesting to be able to call out to Pipes from your server-side web-app, but what the mashup-mad word REALLY needs is to be able to do the same thing from a browser. Despite not really being in the docs anywhere, Yahoo’s Kent Brewster points out that Pipes supports a JSON-P callback argument. Awesome!
The structure of Pipes URLs are different than every other Yahoo service (much like flickr. ugg.), so there’s no Dojo RPC for it yet, but you can easily query a pipe using dojo.io.bind and the ScriptSrcIO transport:
// get news results for Cometd
dojo.require("dojo.io.ScriptSrcIO"); // the x-domain magic
dojo.require("dojo.debug.console"); // firebug integration
dojo.io.bind({
// grab this URL from the pipe you're interested in
url: "http://pipes.yahoo.com/pipes/fELaGmGz2xGtBTC3qe5lkA/run",
mimetype: "text/json",
transport: "ScriptSrcTransport",
jsonParamName: "_callback", // aha!
content: {
"_render": "json",
"textinput1": "cometd"
},
load: function(type, data, evt){
// log the response out to the Firebug console
dojo.require("dojo.json");
dojo.debug(dojo.json.serialize(arguments));
}
});
Pipes is a bit slow right now, so you might not want to use this for main page content, but it’s a great way to decorate pages, blogs, and other kinds of data with a lot more context from all over the web.
7 Comments
I tried with the following code:
<script language=”JavaScript” type=”text/javascript”>
// get news results for Cometd
dojo.require(“dojo.io.ScriptSrcIO”); // the x-domain magic
dojo.require(“dojo.debug.console”); // firebug integration
dojo.io.bind({
// grab this URL from the pipe you’re interested in
url: “http://pipes.yahoo.com/pipes/fELaGmGz2xGtBTC3qe5lkA/run”,
mimetype: “text/json”,
transport: “ScriptSrcTransport”,
jsonParamName: “callback”, // aha!
content: {
“_render”: “json”,
“textinput1″: “cometd”
},
load: function(type, data, evt){ dojo.require(“dojo.json”); dojo.debug(dojo.json.serialize(arguments)); }
});
</script>
But i obtain an “invalid label” error on run line 1, debugging it with firebug.
What’s wrong?
Hey, thanks for the link, Alex. Pipes is getting faster; here’s <a href=”http://kentbrewster.com/badger/?cb=666&ch=776&cf=000&bh=ddd&bf=eee&fh=Alex%20Russell’s%20Blog&fp=http%3A%2F%2Falex.dojotoolkit.org%2F&fu=http%3A%2F%2Falex.dojotoolkit.org%2F%3Ffeed%3Datom&bw=240″>your feed</a>, badged up with Pipes and ready to include on the arbitrary page of anyone’s choice.
Michele may want to use _callback and not callback (note underscore) as her jsonParamName.
Arrgh, sorry, not sure what happened to that link … let’s try it again:
Here’s Alex Russell’s Blog, all badgered up and ready to go.
Yes, that was the problem. I don’t understand why in Yahoo API it’s callback and in Yahoo pipes it’s _callback. Anyway, thank you very much!!!
OFFTOPIC
Your archive is not workink
Pipes is even more powerful now when has the reg exp operator. I’m reading this tutorial ( http://theytookmystapler.blogspot.com/2007/09/yahoo-pipes-case-study-of-using-regex.html ) on it, I will use Pipes with the reg exp operator to change the titles of my Flickr pictures.
4 Trackbacks
[...] Nur weil ich in letzter Zeit schon soviel zu Dojo und Yahoo! abgelassen habe, ganz kurz:Yahoo Pipes Support in Dojo [via Ajaxian]. [...]
[...] Yahoo Pipes Support in Dojo We make it easier to work with Yahoo’s services than Yahoo does.” That is what Alex believes as he announces that Dojo supports Yahoo! Pipes, which adds to the forward-thinking JSON-P style endpoints. (tags: Dojo Pipes) [...]
[...] “We make it easier to work with Yahoo’s services than Yahoo does.” That is what Alex believes as he announces that Dojo supports Yahoo! Pipes, which adds to the forward-thinking JSON-P style endpoints. It’s cool and interesting to be able to call out to Pipes from your server-side web-app, but what the mashup-mad word REALLY needs is to be able to do the same thing from a browser. Despite not really being in the docs anywhere, Yahoo’s Kent Brewster points out that Pipes supports a JSON-P callback argument. Awesome! [...]
[...] Yahoo Pipes Support in Dojo Dojo’s Alex Russell demonstrates how to use undocumented support for JSON-P in the new Yahoo! Pipes service to pull information from Pipes from JavaScript running in the browser (no server-side proxy required). (tags: javascript ajax) [...]