Documentation

Added in v3.23 (CMUDPro/TeSSH ONLY)

url

Syntax: %url(url)

Creates and returns a URL object that can be used to perform HTTP GET/POST operations. Allows you to retrieve data from remote web sources.

NOTE: This function is only available in CMUDPro (and TeSSH)

The following properties and methods are available on the object returned from the %url function:

Properties

  • Host : Sets or retrieves the Hostname field for the current URL.
  • Port : Sets or retrieves the Port field for the current URL
  • Protocol : Sets or retrieves the Protocol field for the current URL. Typically the Protocol field is "http".
  • Path : Sets or retrieves the Path field for the current URL.
  • Filename : Sets or retrieves the Filename field for the current URL.
  • Anchor : Sets or retrieves the Anchor field for the current URL.
  • Username : Sets or retrieves the Username field for the current URL, used for some web page authentication.
  • Password : Sets or retrieves the Password field for the current URL used for some web page authentication.
  • URL : Sets or retrieves the full URL (URI) string
  • ParamStr : Sets or retrieves the full query string of the current URL.
  • Params : A database variable that can be used to set or retrieve query string parameters by key or index value
  • PostParamStr : Sets the full POST parameters string value
  • PostParams : A database variable that can be used to set or retrieve POST parameters by key or index value
  • ContentType : Returns the type of result in MIME format, such as "text/html".
  • ContentLength : Returns the length of content from a Get or Header method.
  • ContentData : Returns the date of the content
  • ContentExpires : Returns the expiration date of the content
  • ContentModified : Returns the date the content was last modified
  • ContentLanguage : Returns the language of the content
  • Location : Returns the Location header of a HTTP redirection request.
  • ResponseCode : Returns the numeric HTTP Response code
  • ResponseText : Returns the full response status text
  • ProxyHost : the IP address or host name of a web proxy server.
  • ProxyPort : the port number of a web proxy server
  • ProxyUsername : when using a web proxy server that requires login, this is the login username.
  • ProxyPassword : when using a web proxy server that requires login, this is the login password.

Methods

  • Get : Performs an HTTP GET request on the URL and returns the full string result
  • Post : Performs an HTTP POST request, sending the PostParams and returns the full string result
  • Header : Performs an HTTP HEAD request and returns the full string result
  • Browse : Opens the URL in an external web browser
  • Download(Filename, method) : Downloads the URL to the specified local file. If "method" is present and true (1) then a POST is used instead of a GET to download the remote file.

Example

u = %url("www.google.com")
#SHOW @u.Get
Displays the HTML returned from the google.com home page.

u = %url("www.server.com")
@u.PostParams.name = zugg
@u.PostParams.key = value
s = @u.Post

Performs an HTTP POST with the PostParams string of "name=zugg&key=value" and stores the result in the @s variable.

Add comment

Login or register to post comments