Using Name-Value Pairs in the Post Web Data Action

The Post Web Data action is used when you publish to the web or to Opus Flex. This action allows you to send information to or receive information from a Server. However, information can only be sent over the web using a special protocol known as CGI (Common Gateway Interface). CGI allows a web browser to communicate with a web Server and pass information to and from it.

Note:
In order for you to send information to or from a Server using the Post Web Data action, you must understand how to communicate with the web Server. This means that someone in the development team must be able to write cgi-scripts so that you can pass information between your Opus publication and the web Server.

Explaining cgi-scripts:

Perl is one of the most popular programming languages used to create cgi scripts. In basic terms, a Perl script is the communication script between your publication and the data you want to send to or receive from the web Server.

When the Post Web Data action is triggered it creates a long string of text to the requested URL. The string will look something like this:

http://www.digitalworkshop.com/cgi-bin/results.pl?user=John&score=10

In the example above, the string sends two bits of information (user=John and score=10) to a Perl script (named results.pl). The two bits of information are sent using a procedure known as Name-Value pairs:

Name

Value

user

John

score

10

The important part of the Perl script as far as Opus users are concerned is that it extracts the name (e.g. user) and the value (e.g. John) and then performs whatever functions have been written in the script for these values, such as sending them to a database or calculating a result, and so on. This information (or any other name-value pairs) can be sent back to the Opus publication using the Post Web Data action again.

Both the Variable and MultipleFields options in the Post Web Data action use this name-value pair data to send and receive information to the cgi-script. These are described in detail below.

The Variable option:

1.  The Variable option allows you to send or receive a single bit of information.

2. The Opus variable you enter in this field can be any system or user variable you have in your publication.

3. The contents of the Opus variable are sent to the web Server and processed by the cgi-script.

4. When the data is sent from Opus to the web Server, the name of the variable is data and the content is the value contained in the Opus variable. For example:

In Opus

In Perl Script

Opus variable is called: userName

Name = data

Contents of the variable is: John Smith

Value = John Smith

5. Therefore, when using the Variable option, the cgi-script must look for the name called data.

Note:
When sending information to the cgi-script, the value can be the contents of any Opus variable but the name sent will be called data.

 When receiving information from the cgi-script, the value returned is from the name data. The value can be stored within your publication in any Opus variable.

The Multiple Fields option:

1. The Multiple Fields option allows you to send or receive more than one bit of information.

2. Click on the Add button to add a new entry. You have to enter two bits of information for each value you want to send or receive: the String and the Variable names, described below:

3. The String is the name part of the name-value pair used by the cgi-script. For example:

Name

Value

user

 

 The script will search for a field with the name user.

Note:
By default, the first time you click the Add button, the string is called param0, the second time param1, and so on. You can change the default name given by clicking on the string name once, which will then allow you to type your own name for the field.

4. The Variable is the name of the Opus variable, which contains the value part of the name-value pair used by the cgi-script: For example:

Name

Value

 

John Smith

Note:
When sending information to the cgi-script, the value can be the contents of any Opus variable.

When receiving information from the cgi-script, the value can be stored within your publication in any Opus variable.

5. Click on the Add button again to add a new entry.

6. Once you have added one entry in the list, the Delete button will become active. To delete an entry, select the entry from the list and click on the Delete button.

7. When you have entered more than one entry in the list, the Up and Down buttons will become active. You can re-order the position of an entry on the list by selecting the entry and then clicking on the Up and Down button as required.

Related Topics:

The Post Web Data action