getMarkupFromUrl
Use this function to retrieve the correct markup for the mobile device, by specifying a url that outputs WAPL.
- 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
PHP Example
Nb. The example below uses 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
- $url = 'http://wapl.info/files/examples/hello_world_1.xml';
-
- $headers = '';
- foreach($_SERVER as $key => $val)
- {
- $headers .= $key.':'.$val.'|';
- }
-
- $postfields = array(
- 'devKey' => 'YOUR_DEV_KEY',
- 'waplUrl' => $url,
- 'headers' => $headers
- );
-
- $c = curl_init();
- curl_setopt($c, CURLOPT_URL, 'http://webservices.wapple.net/getMarkupFromUrl.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>