Fetching Data from a Web Server

 

 

%%httpget%%

 

 

ListManager can retrieve data from a remote machine using the httpget mail merge tag. This data must be accessible via http. The syntax of the httpget tag is:
 

%%httpget "URL"%%

 

The URL argument can be virtually anything you can pull up with a web browser. The URL may point to a simple text file, some HTML code, or a CGI script. To use httpget, you must be using ListManager Pro or Enterprise, and Scripting Level must be set to Full. Httpget will fetch the data for each recipient.

 

Example 1

 

You keep dozens of ads on your web server. You want them to be inserted into your newsletter, with every recipient getting a randomly selected one. The script's URL is http://yourserver/cgi-bin/ad.pl.
 

%%httpget "yourserver/cgi-bin/ad.pl"%%

 

Note that you don't need http:// as part of the URL.

 

Example 2

 

You have a script which creates a different page for each user.

 

The following example shows how to use this to fetch custom data for your member:

 

%%httpget "localhost/cgi-bin/getdata.pl?id=[merge members_.emailaddr_]"%%

 

In the above example, ListManager first performs a substitution to merge in the member’s email address, then retrieves the data at the resulting URL. Note that you must use square brackets and the full mail merge tag, not the short tag. Let’s assume that bob@example.com is the member that ListManager is currently sending to. After substitution, the URL looks like:
 

http://localhost/cgi-bin/getdata.pl?id=bob@example.com

 

The nature of the script being called ("getdata.pl" in this case) is to generate some data unique to the member with that email address. This script can do whatever you design it to do, whether that means generating an ad or retrieving billing information.

 

For programmers, this means you have the ability to call a function in the middle of your message and insert whatever it returns right into the message at the point from which it was called.

 

While the httpget merge tag does not require any specific output from the URL, it is highly recommended that you include a standard 'HTTP/1.0 200 OK' status line, then a 'Content-Type: text/plain', or 'Content-Type: text/html' line followed by an empty line and the content of the text to be inserted. For example, a (Perl) script might have:

 

print "HTTP/1.0 200 OK\r\n";
print "Content-Type: text/plain\r\n";
print "\r\n";
print "Hello! Please buy our products!";

 

%%httpget_auth%%

 

If you have http authentication on the page you want to fetch, you can use httpget_auth, which allows specification of a username and password for basic http authentication.

 

Example

 

%%httpget_auth "http://www.example.com/private/content.html" "administrator" "mypassword"%%

 

 

%%before ; httpget%%

 

Httpget will repeatedly retrieve the data for each individual recipient. If, however, you only need to retrieve the data only once per mailing attempt, you can use the before; httpget tag instead. That is, before the mailing or retry begins, ListManager will pull the URL once, and fill in that same value for all recipients. Since the speed of httpget depends on the speed it can fetch data from your server, using before ; httpget can make your mailing speeds faster.

 

The syntax of the before httpget tag is:
 

%%before ; httpget "URL"%%

 

Note that the httpget will still be run again for each retry.

 

Example

 

You keep dozens of ads on your web server. You want them to be inserted into your newsletter, with every recipient getting the same one. The script's URL is http://www.lyris.com/getmailad.pl.

 

%%before ; httpget "www.lyris.com/getmailad.pl"%%

 

For more information, see Script Execution Points.

 

%%after ; httpget%%

 

If you want to run a function after a message is sent, you can use the after httpget tag. ListManager will call the URL only once, at the conclusion of the message send attempt.

 

The syntax of the after ; httpget tag is:
 

%%after ; httpget "URL"%%

 

Example

 

After a message is sent, you want it to be logged in your database.

 

%%after ; httpget http://www.lyris.com/logsentmessage?id=[merge outmail_.messageid_] %%

 

 

For more information, see Script Execution Points.

 

 

     More

 

1.   Using Mail Merge Tags

2.   Mail Merge Short Tags

3.   How to Format Dates

4.   Fetching Data from a Web Server

5.   Troubleshooting Merge Tag Problems

 

 

 



How To Format Dates Troubleshooting Merge Tag Problems