getMarkupFromWapl
Use this function to pass WAPL as a string and receive the correct markup for the device.
- devKey - used for authentication and to log usage.
- wapl - WAPL passed as a string.
- headers - the headers of the device you wish to query.
Returns:
Upon success, XML containing header information and markup for the device
Upon failure, error codes WAPL markup
PHP Example
Nb. The example below CURL in PHP. The code is for demonstration purposes only and should be modified for use in a production environment.
- <?php
-
- // XML headers and open
- $string = '<' . '?xml version="1.0" encoding="utf-8" ?'.'><wapl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://wapl.wapple.net/wapl.xsd">';
-
- // Page title and external CSS
- $string .= '<head><title>Your Page Title</title>';
- $string .= '<css><url>http://your-domain/css/mobile.css</url></css>';
- $string .= '</head><layout>';
-
- // Add your WAPL below
- $string .= '<row><cell><chars><value>Hello World</value></chars></cell></row>';
-
- // Close layout
- $string .= '</layout></wapl>';
-
- // Setup parameters for communicating
- $headers = '';
- foreach($_SERVER as $key => $val)
- {
- $headers .= $key.':'.$val.'|';
- }
-
- $postfields = array(
- 'devKey' => 'YOUR_DEV_KEY',
- 'wapl' => $string,
- 'headers' => $headers
- );
-
- $c = curl_init();
- curl_setopt($c, CURLOPT_URL, 'http://webservices.wapple.net/getMarkupFromWapl.php');
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($c, CURLOPT_POST, 1);
- curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
-
- $result = curl_exec($c);
- curl_close($c);
-
- $xml = simplexml_load_string($result);
- foreach($xml->header->item as $val)
- {
- header($val);
- }
- echo trim($xml->markup);
-
- ?>
Parsed XML Response
- <wapple_response>
- <session_id>
- 842gsi2c1t16ggcf5pfqjhgnp0
- </session_id>
- <header>
- <item></item>
- <item></item>
- <item></item>
- <item></item>
- <item></item>
- </header>
- <markup>
-
- </markup></wapple_response>