Skip to main content

gadgets.io


Method​

gadgets.io.encodeValues​

<static> String encodeValues(fields)

Converts the input object into a URL-encoded data string(key=value&...)

Parameter​
NameTypeDescription
fieldsObjectThe POST data to be encoded
Return value​
TypeDescription
StringProcessed POST data. An ampersand (&) is added to the end.
Sample​
var postData = {param: "Hello"};
var params = {};
params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postData);

gadgets.io.getProxyUrl​

Not supported.

gadgets.io.makeRequest​

<static> String makeRequest(url, callback, opt_params)

Acquires contents from the specified URL. Results are returned to the callback function.gadgets.io.RequestParameters.
If a value other than gadgets.io.ContentType.TEXT is assigned as the CONTENT_TYPE, the object data field, which can be received as a callback function, will be converted into an appropriate JS object according to the assigned ContentType. For example, if DOM is assigned, it will be converted into a JS object in which a DOM tree structure is nested, and if JSON is assigned, it will be a JS object that maintains a JSON structure. The unconverted, original response body can be acquired in the text field.

Parameter​
NameTypeDescription
urlStringThe URL that contains the contents.
callbackFunctionThe callback function that is called after the contents are acquired and the results turned into arguments.
opt_paramsMap.<gadgets.io.RequestParameters, Object>gadgets.io.RequestParameters or gadgets.io.ProxyUrlRequestParameters
Return value​

None

Sample​
var callback = function(res) {
var data = res.data;
//...
};
var url = "`http://example.com";`
var postData = {param: "Hello"};
var params = {};
params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postData);
gadgets.io.makeRequest(url, callback, params);

gadgets.io.AuthorizationType​

gadgets.io.AuthorizationType.NONE​

A request without authorization.

gadgets.io.AuthorizationType.SIGNED​

A signed request according to the container.

gadgets.io.AuthorizationType.OAUTH​

Not supported.

gadgets.io.ContentType​

gadgets.io.ContentType.TEXT​

Returns text. It is used to acquire HTML.

gadgets.io.ContentType.DOM​

Returns a DOM object. It is used to acquire XML.

gadgets.io.ContentType.JSON​

Returns JSON.

gadgets.io.ContentType.FEED​

Returns a JSON string of an RSS/Atom feed.

gadgets.io.MethodType​

gadgets.io.MethodType.GET​

Specifies the HTTP method GET when acquiring contents. This is the default.

gadgets.io.MethodType.POST​

Specifies the HTTP method POST when acquiring contents.

gadgets.io.MethodType.PUT​

Specifies the HTTP method PUT when acquiring contents.

gadgets.io.MethodType.DELETE​

Specifies the HTTP method DELETE when acquiring contents.

gadgets.io.MethodType.HEAD​

Specifies the HTTP method HEAD when acquiring contents.

gadgets.io.ProxyUrlRequestParameters​

gadgets.io.ProxyUrlRequestParameters.REFRESH_INTERVAL​

Not supported.

gadgets.io.RequestParameters​

gadgets.io.RequestParameters.AUTHORIZATION​

The type of authentication used when acquiring contents. The default is AuthorizationType.NONE.

gadgets.io.RequestParameters.CONTENT_TYPE​

The type of contents. The default is ContentType.TEXT.

gadgets.io.RequestParameters.NUM_ENTRIES​

The number of entries acquired when the contents are fed. The default is 3.

gadgets.io.RequestParameters.GET_SUMMARIES​

It indicates whether or not a feed summary is acquired when the contents are fed. The default is false.

gadgets.io.RequestParameters.HEADERS​

The HTTP header specified when acquiring contents. The default is null.

gadgets.io.RequestParameters.METHOD​

The HTTP method used when acquiring contents. The default is MethodType.GET.

gadgets.io.RequestParameters.POST_DATA​

The data sent using the POST method when acquiring contents. The default is null.

gadgets.io.RequestParameters.REFRESH_INTERVAL​

The number of seconds the container should cache the given response. The default is 3600.
Specifying 0 means no cache for any requests.

Revision History​

  • 09/11/2012
    • Add description for gadgets.io.RequestParameters.REFRESH_INTERVAL
  • 12/2010
    • Initial Release.