These high-level functions enable implementation of custom Internet clients such as Webmail or web-based FTP services, information gathering agents, server farm synchronization daemons, or any other type of TCP/IP services you can dream up.
See the Web and Session Utilities library if you need to work with HTTP client services like sessions, cookies, or file uploads.
parseMail (rfc822-string) |
Returns: list | Location: NetworkLib | ||||
If given an RFC822-formatted e-mail message in CRLF format (returned from POP3GetMessage(), read from an archived mail file, or from another srouce), this function returns a structured list containing the various elements of the message data. The following items are in the returned list:
See Also: |
POP3Connect ( host, pop3-user, pop3-password ) |
Returns: pop3-link | Location: NetworkLib | ||||||||
Initiates a connection to the POP3 server running on the host specified by hostname to the mailbox specified by pop3-user and pop3-password. Returns a POP3 connection link which may be used with other functions in the POP3 function suite. Example: pop3_link = POP3Connect("mail.mydomain.com", mail_user, mail_pass); // you'll get a 0 for this value if the connect fails! if (pop3_link != 0) then print "# of listsucker msgs: " & POP3CountMessages(pop3_link)); end if; See Also: |
POP3CountMessages ( pop3-link ) |
Returns: integer | Location: NetworkLib | ||||
Returns the number of messages in the mailbox specified by pop3-link. See Also: |
POP3DeleteMessage ( pop3-link, message-index ) |
Returns: null | Location: NetworkLib | ||||||
Marks the message with index message-index for deletion. The message is no longer available to other POP3 functions, and will be erased once POP3Disconnect() is called on the connection and the mailbox is closed. See Also: |
POP3Disconnect ( pop3-link ) |
Returns: null | Location: NetworkLib | ||||
Closes the connection specified by pop3-link. See Also: |
POP3GetMessage ( pop3-link, message-index ) |
Returns: string | Location: NetworkLib | ||||||
Returns the text of the email message specified by message-index, which refers to the index of the desired item in the remote mailbox (1 for the first email, 2 for the second, etc.). The returned text is an RFC822-formatted message, using CRLF formatting. See Also: |
POP3ListMessages ( pop3-link ) |
Returns: list | Location: NetworkLib | ||||
Returns a list of sub-lists, one item for each message in the mailbox specified by pop3-link. Each sub-list contains the following items:
See Also: |
sendEmail ( host, to-address, from-address, message-subject, message-body ) |
Returns: null or list | Location: NetworkLib | ||||||||||||
This function will send an Internet e-mail message using the SMTP server specified by the mail-host parameter. The to-address parameter may be a single string or a list of addresses. If the mail is successfully sent, the function will return null. If the e-mail cannot be sent due to an error, a list will be returned as [error-number, error-message]. If you require logging of unsent mail, script a conditional routine to log any mail messages that can not be sent. Examples:
The NetworkLib library provides some preferences which may be set to control how this function is used in a shared server environment. These options may be set by choosing "NetworkLib Prefs..." from the Edit menu within the WebSiphon application. Using the preferences panel, you can set a default mail host to use for all e-mail, overriding the one specified in the mail-host parameter. A maximum number of allowed addresses in the to-address parameter may also be specified. |
HTTPGet ( host, uri [, auth-user, auth-password, user-agent ]) |
Returns: list | Location: NetworkLib | ||||||||||||
Retrieves the specified uri from host using the standard HTTP GET method. The optional parameters auth-user and auth-password are used to access pages protected by basic authenticated realms. If you wish to set a custom user agent string in the HTTP request, use the optional user-agent parameter. Returns a structured list describing the results:
Note: URI Data and HTTP Response Headers are each returned as a binary data type. Use binaryToString() to convert to string if you need to work directly with this data. Example: // retrieve default page from the Purity server remote_host = "www.purity.com"; user_string = "CheesyPoofs/1.0 (WebSiphon 2; Mac; PPC)"; the_result = HTTPGet(remote_host, "/", null, null, user_string); // display results setMIMEType("text/plain"); print "Result Code: " & the_result'1 & "\r"; print "MIME Type: " & the_result'2 & "\r"; print "Response Headers: " & binaryToString(the_result'4) & "\r"; print "Response Data: \r\r" & binaryToString(the_result'3); |
HTTPPost (host, uri, post-arguments [, auth-user, auth-password, user-agent ]) |
Returns: list | Location: NetworkLib | ||||||||||||||
HTTPPost() retrieves the results using the specified URI form POST action at host using the standard HTTP POST method. Pass POST arguments as a list of name/value pairs. The optional parameters auth-user and auth-password are used to access pages protected by HTTP basic authenticated realms. If you wish to set a custom user agent string in the HTTP request, use the optional user-agent parameter. Returns a structured list describing the results:
Note: URI Data and HTTP Response Headers are each returned as a binary data type. Use binaryToString() to convert to string if you need to work directly with this data. Example: post_args = [["name" "Mark Holtz"] ["site" "www.intermag.com"] ["package" "Babel 1.0a1"]]; the_result = HTTPPost("www.intermag.com", "/", post_args, null, null, "CheesyPoofs/1.0 (WebSiphon 2; Macintosh; PPC)"); setMIMEType("text/plain"); print "Result Code: " & the_result'1 & "\r"; print "MIME Type: " & the_result'2 & "\r"; print "Response Headers: " & binaryToString(the_result'4) & "\r"; print "Response Data: \r\r" & binaryToString(the_result'3); |
FTPConnect (host, ftp-user, ftp-pass [, ftp-account, server-port, use-passive ]) |
Returns: ftp-link | Location: NetworkLib | ||||||||||||||
Initiates a connection to the FTP server running on host, given the login credentials ftp-user, ftp-pass and the optional ftp-account parameters. If the server is running on a port other than the default port 21, this is specified using the server-port parameter. Finally, the boolean value use-passive specifies whether or not this connection should use active or passive mode in handling future FTP calls. Returns an FTP connection link which may be used by other functions in the FTP suite. Example: // connect to FTP server and output contents of home directory ftp_link = FTPConnect("ftp.mydomain.com", ftp_login, ftp_pass); if (ftp_link != 0) then printList(FTPListDir(ftp_link, "/")); end if; See Also: |
FTPDeleteFile ( ftp-link, object-path ) |
Returns: null | Location: NetworkLib | ||||||
Permanently removes the remote object specified by object-path. Use this function with caution, as it is irreversible. |
FTPDeleteDir ( ftp-link, directory-path ) |
Returns: null | Location: NetworkLib | ||||||
Permanently removes the remote directory specified by del-dir-path. Use this function with caution, as it is irreversible. |
FTPDisconnect ( ftp-link ) |
Returns: null | Location: NetworkLib | ||||
Closes the FTP session specified by ftp-link. See Also: |
FTPGetFile ( ftp-link, remote-path, destination-path ) |
Returns: null | Location: NetworkLib | ||||||||
Retrieves the file specified by remote-path and archives locally to the file specified by destination-path. Transfers are performed using FTP binary mode, and the destination file is either created or overwritten depending on conditions. The remote-path may be relative to the current working FTP directory, or a full path to the file on the FTP server. |
FTPListDir ( ftp-link [, directory-path ]) |
Returns: list | Location: NetworkLib | ||||||
Returns a list containing one string item for each item in the specified directory (or in the current directory iff none is specified). This string may vary depending on the remote FTP server, but usually contains filename, permission, size, and mod-date data. |
FTPPutFile ( ftp-link, local-path, destination-path ) |
Returns: null | Location: NetworkLib | ||||||||
Puts the local file specified by local-path to the remote FTP location specified by destination-path. Transfers are performed using FTP binary mode. |