You want to make HTTP requests using Server-Side ActionScript (SSAS).
Use the CF.http( ) method.
The Server-Side ActionScript CF.http( ) method enables you to make HTTP requests to any resource available on the Web. This is a convenient way to run server-side scripts on remote domains and return those values to Flash.
The CF.http( ) method accepts the following parameters:
The URL to the requested resource (e.g., "http://www.remotedomain.com/logicalPath/page.cfm") or the protocol and server address/domain name (e.g., "http://www.remotedomain.com/"). You may also need to specify values for the path and file parameters when you use the second format.
Either "post" or "get", corresponding to the HTTP method (POST or GET) used to send any parameters.
If you do not include the logical path and filename in the url parameter, then you should indicate the logical path with the path parameter. For example, if the resource is "http://www.remotedomain.com/logicalPath/page.cfm", and you use the value "http://www.remotedomain.com" for the url parameter, then you should set path to "/logicalPath".
The filename of the requested resource when you do not include it in the url parameter. For example, if the resource is "http://www.remotedomain.com/logicalPath/page.cfm", and you use the value "http://www.remotedomain.com/" for the url parameter, then you should set file to "path.cfm".
The username, if required.
The password, if required.
A value of either "yes" or "no". If "yes", then relative links and references within the remote document are converted to absolute references. The values of the url and path parameters are used for this purpose. For example, if the url parameter is "http://www.remotedomain.com", and the path parameter is "/logicalPath", then an HTML tag in the remote document such as <a href="pages/myPage.cfm"> is converted to <a href="http://www.remotedomain.com/logicalPath/pages/myPage.cfm"> in the returned value.
The params parameter contains the values (if any) that are sent to the resource, and it should be in the form of an indexed array of objects with the following properties:
The variable name.
The variable value.
The scope for the variable. The possible values for type are "URL", "FormField", "Cookie", and "CGI".
You can pass the arguments to CF.http( ) as either positional or named parameters. If you use positional parameters, the following is a list of possible parameter orders:
CF.http(url); CF.http(method, url); CF.http(method, url, username, password); CF.http(method, url, params, username, password);
Notice that path, file, and resolveurl are not available when using positional parameters. If you want to use these parameters, you must use named parameters.
The CF.http( ) method returns an associative array with the following properties:
The raw response header.
The character the requested resource uses.
The mime type of the requested resource.
The status code, such as "200 OK" or "500 Internal Server Error".
The response header as an associative array. Each response header key (such as Date, Server, etc.) is an element of the associative array.
A Boolean value. The value is true if the requested resource contains text, and false otherwise.
The contents of the requested resource.
Most of the time, you should return the result of a CF.http( ) to the Flash movie, and you can process the result as a normal ActionScript associative array within the client movie. However, if you want to process the result using SSAS, be aware that on the server, the object is actually an ASObject. Therefore, you must use the ASObject methods (ASObject subclasses java.util.HashMap) to process the result of a CF.http( ) method invocation within SSAS:
// Get the contents of http://www.person13.com and assign the result to httpResult. var httpResult = CF.http("http://www.person13.com"); // Extract the value of the FileContent element using the get( ) method. var fContent = httpResult.get("FileContent");
Recipe 20.21