Study Guide

Table Of Contents
PayPal Certified Developer Program Study Guide March 2008 55
Name-Value Pair (NVP) API
Technical Details
5
z The name is separated from the value by an equals sign (=); for example:
FIRSTNAME=Robert
z Name-value pairs are separated by an ampersand (&); for example:
FIRSTNAME=Robert&MIDDLENAME=Herbert&LASTNAME=Moore
z The NVP string is URL-encoded.
URL Encoding
You must URL encode the values included in each API request. The values in all API
responses are also URL encoded. URL encoding ensures the proper transmission of special
characters, characters that are not allowed in a URL, and characters that have special meaning
in a URL, such as the equal sign and ampersand. For example, notice the following NVP
string:
NAME=Robert Moore&COMPANY=R. H. Moore & Associates
The NVP string is URL-encoded as follows:
NAME=Robert+Moore&COMPANY=R%2E+H%2E+Moore+%26+Associates
Use the methods listed in Table 5.1 to URL-encode or URL-decode NVP strings.
TABLE 5.1 URL-Encoding Methods
Language
Encode/
Decode Method
ASP.NET Encode System.Web.HttpUtility.UrlEncode(buffer,
Encoding.Default)
Decode System.Web.HttpUtility.UrlDecode(buffer,
Encoding.Default)
Classic ASP Encode Server.URLEncode
Decode No built-in function
ColdFusion Encode URLEncodedFormatstring [, charset]
Decode URLDecodeurlEncodedString[, charset]
Java Encode java.net.URLEncoder.encode
Decode java.net.URLEncoder.decode
PHP Encode urlencode()
Decode urldecode()