Steven Olmsted![]()
This is a simple REST client supporting DELETE, GET, HEAD, POST, and PUT.
There will probably be some API sugar in the future. For now, there is one method, Y.YQLRESTClient.request, that takes a kitchen sink object, a callback function, a yql params object, and a yql opts object.
The params and opts object are passed through to Y.YQL, reference the docs there.
On success, the callback function is passed an object containing headers, url, response, and status.
The kitchen sink parameters object may have the following members:
accept - Specifies the type of content to send in the response using the Accept HTTP header. This tells YQL what kind of data format you want returned, as well as how to parse it.
content - The body content of a POST or PUT request.
contentType - Specifies the content-type of the body content of a POST or PUT request.
fallbackCharsets - Overrides the list of fallback character sets, which is set to "utf-8, iso-8859-1" by default, for decoding the returned response. YQL attempts to decode the response using the character sets listed here when the response either does not specify the character set or specifies an incorrect character set that results in a failed decoding. This value may be an array of strings or one string with comma separated values.
forceCharset - Forces YQL to use the character set specified. Using this overrides both the character set specified by the response and the fallback character sets.
headers - Adds HTTP headers to the request.
jsonCompat - Set this value to 'new' to get "lossless" JSON when making a REST call to a Web service. jsonCompat: 'new' must also be set in the yqlParams object.
matrix - Adds matrix parameters to the request.
method - The HTTP method to use. Must be one of 'DELETE', 'GET', 'HEAD', 'POST' or 'PUT'.
paths - Array of paths to append to the url.
query - Query parameters to add to the request.
timeout - Specifies the request timeout in milliseconds. This is useful when you want to cancel requests that take longer than expected.
url - Provides a URL endpoint to query.
YQL's REST API docs are a good reference too. These parameter values translate directly into API method calls. http://developer.yahoo.com/yql/guide/yql-javascript-objects.html#yql-execute-yrestobject
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.06.20-20-07'
}).use('gallery-yql-rest-client', function(Y) {
Y.YQLRESTClient.request({
method: 'get',
url: 'http://www.google.com'
}, function (result) {
alert(result.response);
});
});
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info