ARWebUtils

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

Contents

Overview

ARWebUtils provides utility functions working in the security sandbox for third party developers.

These functions are in the ARWebUtils table. See the Web API Overview for a comparison of the available Web functions.

Functions

DownloadFile

DownloadFile(url, options, callback)

Starts downloading a file from the target url. When the download has been completed the callback function will be called back with content data.

You can specify some HTTP request parameters by options described below.

Options

The options parameter may be a table containing following keys:

agent - contents of the User-Agent header (used to identify the browser type). Defaults to "Blue Mars"
referer - contents of the Referer header (used to identify the referring web site). Defaults to "http://www.bluemarsonline.com/"
post - urlencoded post data
redirect - number of redirects to follow. -1 specifies infinite redirects

Example

HTTP GET Method

 ARWebUtils.DownloadFile ("http://www.example.com/path/to/resource?q=blue+mars",
                          {},
                          function (data)
                            System.Log ("Got " .. #data)
                          end)

HTTP POST Method

 ARWebUtils.DownloadFile ("http://www.example.com/path/to/resource",
                          {post = "q=blue+mars"},
                          function (data)
                            System.Log ("Got " .. #data)
                          end)

See Also

ARXmlUtils

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools