YQL 有一个执行方法,可以在输出上运行 JavaScript 以将其转换为所需的格式。这里有一些例子:
<execute><![CDDATA[
// request.url == 'http://some_web_service_or_feed
// This is the same as 'y.rest(request.url).get();'
var returned_response = request.get();
...
]]>
</execute>
<execute><![CDATA[
// Include the OAuth libraries from oauth.net
y.include("http://oauth.googlecode.com/svn/code/javascript/oauth.js");
y.include("http://oauth.googlecode.com/svn/code/javascript/sha1.js");
// Collect all the parameters
var encodedurl = request.url;
var accessor = { consumerSecret: cs, tokenSecret: ""};
var message = { action: encodedurl, method: "GET", parameters: [["oauth_consumer_key",ck],["oauth_version","1.0"]]};
OAuth.setTimestampAndNonce(message);
// Sign the request
OAuth.SignatureMethod.sign(message, accessor);
try {
// get the content from service along with the OAuth header, and return the result back out
response.object = request.contentType('application/xml').header("Authorization", OAuth.getAuthorizationHeader("netflix.com", message.parameters)).get().response;
} catch(err) {
response.object = {'result':'failure', 'error': err};
}
]]>
</execute>
参考