TeraWurfl
[ class tree: TeraWurfl ] [ index: TeraWurfl ] [ all elements ]

Source for file webservice.php

Documentation is available at webservice.php

  1. <?php
  2. /**
  3.  * Tera_WURFL - PHP MySQL driven WURFL
  4.  * 
  5.  * Tera-WURFL was written by Steve Kamerman, and is based on the
  6.  * Java WURFL Evolution package by Luca Passani and WURFL PHP Tools by Andrea Trassati.
  7.  * This version uses a MySQL database to store the entire WURFL file, multiple patch
  8.  * files, and a persistent caching mechanism to provide extreme performance increases.
  9.  * 
  10.  * @package TeraWurfl
  11.  * @author Steve Kamerman <stevekamerman AT gmail.com>
  12.  * @version Stable 2.1.3 $Date: 2010/09/18 15:43:21
  13.  * @license http://www.mozilla.org/MPL/ MPL Vesion 1.1
  14.  */
  15. /*
  16.  * webservice.php provides a method of querying a remote Tera-WURFL for device capabilities.
  17.  * This file requires Tera-WURFL >= 2.1.1
  18.  * 
  19.  * Parameters:
  20.  *     ua: The user agent you want to lookup (url encoded/escaped)
  21.  *  search: The capabilities or groups you are looking for (delimited by '|')
  22.  *  format: (optional) The data format to return the result in: xml or json.  xml is default
  23.  * 
  24.  * Usage Example:
  25.  * webservice.php?ua=SonyEricssonK700i/R2AC%20SEMC-Browser/4.0.2%20Profile/MIDP-2.0%20Configuration/CLDC-1.1&search=brand_name|model_name|uaprof|fakecapa|image_format|fakegroup
  26.  * 
  27.  * Returns:
  28.  * XML data with the results, in the following format:
  29. <?xml version="1.0" encoding="iso-8859-1"?>
  30. <TeraWURFLQuery>
  31.     <device apiVersion="2.1.3" mtime="1276096668" useragent="SonyEricssonK700i/R2AY SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1" id="sonyericsson_k700i_ver1subr2ay">
  32.         <capability name="brand_name" value="SonyEricsson"/>
  33.         <capability name="model_name" value="K700i"/>
  34.         <capability name="uaprof" value="http://wap.sonyericsson.com/UAprof/K700iR101.xml"/>
  35.         <capability name="fakecapa" value=""/>
  36.         <capability name="greyscale" value="false"/>
  37.         <capability name="jpg" value="true"/>
  38.         <capability name="gif" value="true"/>
  39.         <capability name="transparent_png_index" value="false"/>
  40.         <capability name="epoc_bmp" value="false"/>
  41.         <capability name="bmp" value="true"/>
  42.         <capability name="wbmp" value="true"/>
  43.         <capability name="gif_animated" value="true"/>
  44.         <capability name="colors" value="65536"/>
  45.         <capability name="svgt_1_1_plus" value="false"/>
  46.         <capability name="svgt_1_1" value="true"/>
  47.         <capability name="transparent_png_alpha" value="false"/>
  48.         <capability name="png" value="true"/>
  49.         <capability name="tiff" value="false"/>
  50.         <capability name="fakegroup" value=""/>
  51.     </device>
  52.     <errors>
  53.         <error name="fakecapa" description="The group or capability is not valid."/>
  54.         <error name="fakegroup" description="The group or capability is not valid."/>
  55.     </errors>
  56. </TeraWURFLQuery>
  57.  * 
  58.  * You can specify the following options via GET or POST:
  59.  * ua:        User Agent (required)
  60.  * search:    Returns the specified capabilities (e.g. mp3) and groups (e.g. product_info)
  61.  *             Multiple capabilities and groups can be separated by '|'.
  62.  * 
  63.  * This script is designed to always return valid XML data so your client doesn't
  64.  * break.  If your query generated errors, they will be in:
  65.  *         <TeraWURFLQuery>
  66.  *             <errors>
  67.  * Error elements have two properties:
  68.  *         name: The name of the capability or group in error
  69.  *         desc: The description of the error
  70.  * See the example above.  If you searched for an invalid capability or group, it
  71.  * will still be included in the XML data structure, but it will be NULL.
  72.  * 
  73.  * To see the nicely formatted XML output in your browser, you can do this:
  74.  * <code>
  75.  * echo "<pre>".htmlspecialchars(var_export($webservice->getXMLResponse(),true))."</pre>";
  76.  * </code>
  77.  */
  78. require_once realpath(dirname(__FILE__).'/./TeraWurflWebservice.php');
  79. $userAgent array_key_exists('ua',$_REQUEST)$_REQUEST['ua']null;
  80. $searchPhrase array_key_exists('search',$_REQUEST)$_REQUEST['search']null;
  81. $data_format (array_key_exists('format',$_REQUEST&& $_REQUEST['format'])$_REQUEST['format']null;
  82. $webservice new TeraWurflWebservice($userAgent,$searchPhrase,$data_format);
  83. $webservice->sendResponse();

Documentation generated on Sun, 19 Sep 2010 00:16:09 +0000 by phpDocumentor 1.4.3