Protocols
Lasso contains built-in support for the most common Internet protocols, allowing you to read and write data to and from just about any source.
Sending Email
Lasso has built-in support for sending email messages. You can send password reminders to your site visitors, receipts from your store, or customized newsletters. Create multi-part messages including both text and HTML versions, inline images, and attachments. Lasso can integrate with your existing email server, either sending through a local relay or directly to remote SMTP servers.
// send an email
email_send(
-to='sales@lassosoft.com',
-from=#sender,
-subject='Sales Inquiry',
-body=#msg
)
Checking Email
Lasso allows you to download messages from any POP server. You can create an automatic email archive system, import customer service emails into your site, or implement a webmail system for your visitors to read their own email. Lasso can parse multi-part messages and extract attachments.
// retrieve unread messages from a POP account
local(messages = email_pop(
-host='pop.example.com',
-username='xxxxxxxxx',
-password='xxxxxxxxx'
))
// extract individual messages for processing
iterate(#messages) => {
local(msg = email_parse(#messages->retrieve))
#messages->delete
// process message...
}
#messages->close
// create a JSON object
local(mydata = map('a' = 1, 'b' = 2, 'c' = 3))
local(myJSON = json_serialize(#mydata))
AJAX
Lasso includes tools which make it easy to server data in JSON or XML format for easy integration with client-side AJAX and XHR scripts. Integrate with jQuery or script.aculo.us to provide site interactivity.
Web Pages
Lasso allows web pages to be imported from any server. Lasso can serve as a proxy to a remote website, can mine a remote site for data, or can provide access to CGIs by posting form data to them and parsing the results.
// send some POST arguments to a remote server
// and retrieve the response
local(response = include_url(
'https://www.example.com/a/RESTful/API/',
-username='xxxxxxxxx',
-password='xxxxxxxxx',
-postparams=#postparams,
-timeout=30,
-connecttimeout=30
))
FTP
Lasso includes a set of methods for interacting with remote FTP servers. You can automate fetching files from a remote server or uploading files to an archive.
// list the top level directory of an FTP site
ftp_getlisting(
'ftp://ftp.example.com/',
-username='xxxxxxxxx',
-password='xxxxxxxxx'
)
// download a file
ftp_getfile(
'ftp://ftp.example.com/filetoget.zip',
-file='/downloads/filetoget.zip'
)
// upload a file
ftp_putfile(
'ftp://ftp.example.com/uploads/filetoupload.zip',
-file='/local/files/filetoupload.zip'
)
LDAP
Allows searching through LDAP servers so Lasso can be integrated into an enterprise class authentication system.
// create an LDAP object, open a connection, and authenticate
local(myLDAP = LDAP)
#myLDAP->open('ldap.example.com')
#myLDAP->authenticate('username', 'password')
// send an LDAP query and retrieve the response
local(queryResults = #myLDAP->search(
'dc=example,dc=com',
LDAP_scope_subtree,
'(objectClass=*)',
(: '*'),
false
))
// close the connection
#myLDAP->close
DNS
Built-in support for looking up DNS records of any type including support for IPv6 address, MX records, reverse lookups, and more.
// get the MX records for example.com
local(mx = dns_lookup(
'www.example.com',
-type='MX',
-format
))
Low Level
Lasso provides low-level access to both TCP and UDP communications so support for additional network protocols can be implemented directly in Lasso. Lasso can access remote servers and can listen on ports for incoming communications. Lasso's flexible byte stream processing makes it easy to parse the data from any protocol.