20.23. Making HTTP Requests with Server-Side ActionScript
Problem
You want to make HTTP requests using Server-Side ActionScript (SSAS).
Solution
Use the CF.http( )
method.
Discussion
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:
-
url
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
andfile
parameters when you use the second format.-
method
Either “post” or “get”, corresponding to the HTTP method (POST or GET) used to send any parameters.
-
path
If you do not include the logical path and filename in the
url
parameter, then you should indicate the logical path with thepath
parameter. For example, if the resource is “http://www.remotedomain.com/logicalPath/page.cfm”, and you use the value “http://www.remotedomain.com” for theurl
parameter, then you should setpath
to “/logicalPath”.-
file
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 theurl
parameter, then you should setfile
to “path.cfm”.-
username
Get Actionscript Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.