Http Fetch Field
Important Note
The following mail merge tags, while fully supported in ListManager 5.0, are now obsolete. We recommend you use the new tags described above in Message Personalization and Scripting. In particular, the http fetch command has been replaced by the web fetch command.
Note: the syntax of this merge type is no longer supported. You must use the new Tcl syntax.
You can specify that ListManager retrieve data from a remote machine using the httpget merge tag. This data must be accessible via http. The syntax of the httpget Mail Merge tag is:
<!-- merge type=["httpget" | "httpgetonce"] URL=[URL] -->
Notice the merge syntax is nested in an HTTP comment tag.
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.
For example, consider you want to retrieve an ad you are running on your web server and the URL is http://yourserver/cgi-bin/ad.pl; you would accomplish this by using the following merge tag:
<!-- merge type="httpget" URL="http://yourserver/cgi-bin/getdata.pl" -->
The above example will repeatedly retrieve the data for each recipient. If, however, you only need to retrieve the data once, you can use the httpgetonce tag instead. The following example illustrates this usage:
<!-- merge type="httpgetonce" URL="http://localhost/cgi-bin/getdata.pl" -->
The following example shows how to use this to fetch custom data for your member:
<!-- merge type="httpget" URL="‘’http://localhost/cgi-bin/getdata.pl?id=$subst(‘Recip.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. 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 &GetCurrentTime()."\r\n";