2.2.3 :: getMarkupFromWapl via CURL

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.
  1.  <?php
  2.  
  3.  // XML headers and open
  4.  $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">';
  5.  
  6.  // Page title and external CSS
  7.  $string .= '<head><title>Your Page Title</title>';
  8.  $string .= '<css><url>http://your-domain/css/mobile.css</url></css>';
  9.  $string .= '</head><layout>';
  10.  
  11.  // Add your WAPL below
  12.  $string .= '<row><cell><chars><value>Hello World</value></chars></cell></row>';
  13.  
  14.  // Close layout
  15.  $string .= '</layout></wapl>';
  16.  
  17.  // Setup parameters for communicating
  18.  $headers = '';
  19.  foreach($_SERVER as $key => $val)
  20.  {
  21.   $headers .= $key.':'.$val.'|';
  22.  }
  23.  
  24.  $postfields = array(
  25.   'devKey' => 'YOUR_DEV_KEY',
  26.   'wapl' => $string,
  27.   'headers' => $headers
  28.  );
  29.  
  30.  $c = curl_init();
  31.  curl_setopt($c, CURLOPT_URL, 'http://webservices.wapple.net/getMarkupFromWapl.php');
  32.  curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  33.  curl_setopt($c, CURLOPT_POST, 1);
  34.  curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
  35.  
  36.  $result = curl_exec($c);
  37.  curl_close($c);
  38.  
  39.  $xml = simplexml_load_string($result);
  40.  foreach($xml->header->item as $val)
  41.  {
  42.   header($val);
  43.  }
  44.  echo trim($xml->markup);
  45.  
  46.  ?>

Parsed XML Response


  1.  <wapple_response>
  2.  <session_id>
  3.  842gsi2c1t16ggcf5pfqjhgnp0
  4.  </session_id>
  5.  <header>
  6.  <item><![CDATA[Cache-Control: no-store, no-cache, max-age=0, s-maxage=0, post-check=0, pre-check=0, public, must-revalidate]]></item>
  7.  <item><![CDATA[Pragma: no-cache]]></item>
  8.  <item><![CDATA[Last-Modified: Thu, 25 Sep 2008 16:03:52 GMT]]></item>
  9.  <item><![CDATA[Expires: Thu, 25 Sep 2008 16:03:51 GMT]]></item>
  10.  <item><![CDATA[Content-Type: text/vnd.wap.wml; charset=utf-8]]></item>
  11.  </header>
  12.  <markup>
  13.  <![CDATA[<?xml version="1.0" encoding="utf-8" ?>
  14.  <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
  15.  "http://www.wapforum.org/DTD/wml_1.1.xml">
  16.  <wml>
  17.  <card id="card" title="Wapple Home"><p>
  18.  EXAMPLE WAPL!
  19.  &#160;
  20.  <img src="http://go.wapple.net/sitegraphic/4051_842gsi2c1t16ggcf5pfqjhgnp0_bd0c05cd/bin.jpg" alt="loading." />
  21.  &#160;
  22.  <br />
  23.  </p>
  24.  </card>
  25.  </wml>]]>
  26.  </markup></wapple_response>
Downloadlisting 2.2.3.b

Contents