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
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
- <SOAP-ENV:Body>
- <ns1:getMarkupFromUrl>
- <devKey>Wapple</devKey>
- <waplUrl>http://wapl.info/files/examples/hello_world_1.xml</waplUrl>
- <deviceHeaders>
- <deviceItem>
- <name>HTTP_HOST</name>
- <value>wapple.net</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_USER_AGENT</name>
- <value>LGE-LG380/1.0 UP.Browser/6.2.3.8 (GUI) MMP/2.0</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_CHARSET</name>
- <value>utf-8</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_LANGUAGE</name>
- <value>en; q=1.0, en, *; q=0.5</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT_ENCODING</name>
- <value>deflate,gzip</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_REFERER</name>
- <value>http://www.wapple.net/</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_CACHE_CONTROL</name>
- <value>max-age=259200</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_CONNECTION</name>
- <value>keep-alive</value>
- </deviceItem>
- <deviceItem>
- <name>HTTP_ACCEPT</name>
- <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>
- </deviceItem>
- </deviceHeaders>
- </ns1:getMarkupFromUrl>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
Example SOAP Response
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WaplAPI">
- <SOAP-ENV:Body>
- <ns1:getMarkupFromUrlResponse>
- <?xml version="1.0" encoding="UTF-8" ?>
- <wapple_response>
- <session_id>
- qmseq20kctptvuvme0s60431v7
- </session_id>
- <header>
- <item><![CDATA[Cache-Control: no-store, no-cache, max-age=0, s-maxage=0, post-check=0, pre-check=0, public, must-revalidate]]></item>
-
- <item><![CDATA[Pragma: no-cache]]></item>
- <item><![CDATA[Last-Modified: Thu, 25 Sep 2008 16:03:49 GMT]]></item>
- <item><![CDATA[Expires: Thu, 25 Sep 2008 16:03:48 GMT]]></item>
- <item><![CDATA[Content-Type: text/vnd.wap.wml; charset=utf-8]]></item>
- </header>
-
- <markup>
- <![CDATA[<?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
- "http://www.wapforum.org/DTD/wml_1.1.xml">
- <wml>
- <card id="card" title="Wapple Home"><p>
- Hello World
- &#160;
- <br />
- </p>
-
- </card>
- </wml>]]>
- </markup></wapple_response>
- </ns1:getMarkupFromUrlResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
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>
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.
- <?php
-
- // XML headers and open
- $url = 'http://wapl.info/files/examples/hello_world_1.xml';
-
- // Setup parameters for communicating
- $headers = array();
- foreach($_SERVER as $key => $val)
- {
- $headers[] = array('name' => $key, 'value' => $val);
- }
-
- $params = array('devKey'=>"YOUR-DEV-KEY", 'waplUrl'=>$url, 'deviceHeaders'=>$headers);
-
- // Send markup to API and parse through simplexml
- $sClient = @new SoapClient('http://webservices.wapple.net/wapl.wsdl', array('connection_timeout' => 5));
- $xml = simplexml_load_string($sClient->getMarkupFromUrl($params));
-
- foreach($xml->header->item as $val)
- {
- header($val);
- }
- echo trim($xml->markup);
- ?>