2.1.4 :: getMarkupFromUrl

getMarkupFromUrl



Use this function to retrieve the correct markup for the mobile device, by specifying a url that outputs WAPL.

getMarkupFromUrl(devKey, url, headers)


  • devKey - used for authentication and to log usage.

  • url - an absolute url to a static WAPL document or a script that outputs WAPL.

  • 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

Example SOAP Request


  1.  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
  2.   <SOAP-ENV:Body>
  3.   <ns1:getMarkupFromUrl>
  4.   <devKey>Wapple</devKey>
  5.   <waplUrl>http://wapl.info/files/examples/hello_world_1.xml</waplUrl>
  6.   <deviceHeaders>
  7.   <deviceItem>
  8.   <name>HTTP_HOST</name>
  9.   <value>wapple.net</value>
  10.   </deviceItem>
  11.   <deviceItem>
  12.   <name>HTTP_USER_AGENT</name>
  13.   <value>LGE-LG380/1.0 UP.Browser/6.2.3.8 (GUI) MMP/2.0</value>
  14.   </deviceItem>
  15.   <deviceItem>
  16.   <name>HTTP_ACCEPT_CHARSET</name>
  17.   <value>utf-8</value>
  18.   </deviceItem>
  19.   <deviceItem>
  20.   <name>HTTP_ACCEPT_LANGUAGE</name>
  21.   <value>en; q=1.0, en, *; q=0.5</value>
  22.   </deviceItem>
  23.   <deviceItem>
  24.   <name>HTTP_ACCEPT_ENCODING</name>
  25.   <value>deflate,gzip</value>
  26.   </deviceItem>
  27.   <deviceItem>
  28.   <name>HTTP_REFERER</name>
  29.   <value>http://www.wapple.net/</value>
  30.   </deviceItem>
  31.   <deviceItem>
  32.   <name>HTTP_CACHE_CONTROL</name>
  33.   <value>max-age=259200</value>
  34.   </deviceItem>
  35.   <deviceItem>
  36.   <name>HTTP_CONNECTION</name>
  37.   <value>keep-alive</value>
  38.   </deviceItem>
  39.   <deviceItem>
  40.   <name>HTTP_ACCEPT</name>
  41.   <value>application/vnd.phonecom.mmc-xml, application/vnd.wap.wmlc;type=4365, application/vnd.wap.wmlscriptc, application/vnd.wap.xhtml+xml, application/xhtml+xml;profile="http://www.wapforum.org/xhtml", image/bmp, image/gif, image/jpeg, image/png, image/vnd.wap.wbmp, image/x-up-wpng, multipart/mixed, multipart/related, text/html, text/plain, text/vnd.wap.wml;type=4365, audio/midi, audio/qcelp, audio/vnd.qcelp, application/x-pmd, audio/mid, audio/x-midi, audio/x-mid, audio/mp4, audio/mp3, audio/mpeg4, video/mpeg4, video/mp4, application/vnd.oma.dd+xml, application/vnd.oma.drm.message</value>
  42.   </deviceItem>
  43.   </deviceHeaders>
  44.   </ns1:getMarkupFromUrl>
  45.   </SOAP-ENV:Body>
  46.  </SOAP-ENV:Envelope>
Downloadlisting 2.1.4.a


Example SOAP Response


  1.  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
  2.   <SOAP-ENV:Body>
  3.   <ns1:getMarkupFromUrlResponse>
  4.  &lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  5.  &lt;wapple_response&gt;
  6.  &lt;session_id&gt;
  7.  qmseq20kctptvuvme0s60431v7
  8.  &lt;/session_id&gt;
  9.  &lt;header&gt;
  10.  &lt;item&gt;&lt;![CDATA[Cache-Control: no-store, no-cache, max-age=0, s-maxage=0, post-check=0, pre-check=0, public, must-revalidate]]&gt;&lt;/item&gt;
  11.  
  12.  &lt;item&gt;&lt;![CDATA[Pragma: no-cache]]&gt;&lt;/item&gt;
  13.  &lt;item&gt;&lt;![CDATA[Last-Modified: Thu, 25 Sep 2008 16:03:49 GMT]]&gt;&lt;/item&gt;
  14.  &lt;item&gt;&lt;![CDATA[Expires: Thu, 25 Sep 2008 16:03:48 GMT]]&gt;&lt;/item&gt;
  15.  &lt;item&gt;&lt;![CDATA[Content-Type: text/vnd.wap.wml; charset=utf-8]]&gt;&lt;/item&gt;
  16.  &lt;/header&gt;
  17.  
  18.  &lt;markup&gt;
  19.  &lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  20.  &lt;!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
  21.  "http://www.wapforum.org/DTD/wml_1.1.xml"&gt;
  22.  &lt;wml&gt;
  23.  &lt;card id="card" title="Wapple Home"&gt;&lt;p&gt;
  24.  Hello World
  25.  &amp;#160;
  26.  &lt;br /&gt;
  27.  &lt;/p&gt;
  28.  
  29.  &lt;/card&gt;
  30.  &lt;/wml&gt;]]&gt;
  31.  &lt;/markup&gt;&lt;/wapple_response&gt;
  32.   </ns1:getMarkupFromUrlResponse>
  33.   </SOAP-ENV:Body>
  34.  </SOAP-ENV:Envelope>
Downloadlisting 2.1.4.b


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.  
  8.  <item><![CDATA[Pragma: no-cache]]></item>
  9.  <item><![CDATA[Last-Modified: Thu, 25 Sep 2008 16:03:52 GMT]]></item>
  10.  <item><![CDATA[Expires: Thu, 25 Sep 2008 16:03:51 GMT]]></item>
  11.  <item><![CDATA[Content-Type: text/vnd.wap.wml; charset=utf-8]]></item>
  12.  </header>
  13.  <markup>
  14.  <![CDATA[<?xml version="1.0" encoding="utf-8" ?>
  15.  <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
  16.  "http://www.wapforum.org/DTD/wml_1.1.xml">
  17.  <wml>
  18.  <card id="card" title="Wapple Home"><p>
  19.  SOME FAKE WAPL!
  20.  &#160;
  21.  <img src="http://go.wapple.net/sitegraphic/4051_842gsi2c1t16ggcf5pfqjhgnp0_bd0c05cd/bin.jpg" alt="loading." />
  22.  &#160;
  23.  <br />
  24.  </p>
  25.  </card>
  26.  </wml>]]>
  27.  </markup></wapple_response>
Downloadlisting 2.1.4.c


PHP Example


Nb. The example below uses the native PHP soap extension 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.  $url = 'http://wapl.info/files/examples/hello_world_1.xml';
  5.  
  6.  // Setup parameters for communicating
  7.  $headers = array();
  8.  foreach($_SERVER as $key => $val)
  9.  {
  10.   $headers[] = array('name' => $key, 'value' => $val);
  11.  }
  12.  
  13.  $params = array('devKey'=>"YOUR-DEV-KEY", 'waplUrl'=>$url, 'deviceHeaders'=>$headers);
  14.  
  15.  // Send markup to API and parse through simplexml
  16.  $sClient = @new SoapClient('http://webservices.wapple.net/wapl.wsdl', array('connection_timeout' => 5));
  17.  $xml = simplexml_load_string($sClient->getMarkupFromUrl($params));
  18.  
  19.  foreach($xml->header->item as $val)
  20.  {
  21.   header($val);
  22.  }
  23.  echo trim($xml->markup);
  24.  ?>

Contents