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

Source for file Request.php

Documentation is available at Request.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Contains the Services_Yahoo_Maps_Request class
  7.  * 
  8.  * Copyright 2005 Bryan Dunlap
  9.  *
  10.  * Licensed under the Apache License, Version 2.0 (the "License");
  11.  * you may not use this file except in compliance with the License.
  12.  * You may obtain a copy of the License at
  13.  *
  14.  *     http://www.apache.org/licenses/LICENSE-2.0
  15.  *
  16.  * Unless required by applicable law or agreed to in writing, software
  17.  * distributed under the License is distributed on an "AS IS" BASIS,
  18.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19.  * See the License for the specific language governing permissions and
  20.  * limitations under the License.
  21.  * 
  22.  * @category   Web Services
  23.  * @package    Services_Yahoo
  24.  * @author     Bryan Dunlap <bdunlap@bryandunlap.com>
  25.  * @copyright  2005 Bryan Dunlap
  26.  * @license    http://www.apache.org/licenses/LICENSE-2.0  Apache License, Version 2.0
  27.  * @version    CVS: $Id: Request.php,v 1.2 2006/10/02 12:53:33 mj Exp $
  28.  */
  29.  
  30. require_once "Services/Yahoo/Exception.php";
  31.  
  32. /**
  33.  * Provides the ability to construct a valid Yahoo! Maps API request URL
  34.  *
  35.  * @category   Web Services
  36.  * @package    Services_Yahoo
  37.  * @author     Bryan Dunlap <bdunlap@bryandunlap.com>
  38.  * @copyright  2005 Bryan Dunlap
  39.  * @license    http://www.apache.org/licenses/LICENSE-2.0  Apache License, Version 2.0
  40.  * @version    Release: @package_version@
  41.  */
  42. {
  43.     
  44.     /**
  45.      * Location of the Yahoo! Maps REST service
  46.      *
  47.      * @const
  48.      */
  49.     const REQUEST_URL   = "http://api.maps.yahoo.com/Maps/V1/annotatedMaps";
  50.  
  51.     /**
  52.      * Valid parameters to be passed
  53.      *
  54.      * @var    string 
  55.      * @access private
  56.      */
  57.     private $parameters = array("appid"  => "PEAR_Services_Yahoo",
  58.                                 "xmlsrc" => "");
  59.     
  60.     /**
  61.      * Constructor
  62.      *
  63.      * @param  string $appID   (optional) the string containing the
  64.      *                                     Application ID
  65.      * @param  string $xmlSrc  (optional) the string containing either valid XML
  66.      *                                     or a URL to a valid XML document
  67.      * @access public
  68.      */
  69.     public function __construct($id = null$xmlSrc = null)
  70.     {
  71.         if (!is_null($appID)) {
  72.             $this->setAppID($id);
  73.         }
  74.         if (!is_null($xmlSrc)) {
  75.             $this->setXMLSrc($xmlSrc);
  76.         }
  77.     }
  78.     
  79.     /**
  80.      * Builds a valid Yahoo! Maps REST request URL
  81.      *
  82.      * @return string 
  83.      * @throws Services_Yahoo_Exception
  84.      * @access public
  85.      */
  86.     public function build($urlencode = true)
  87.     {
  88.         if (!$parameters["xmlsrc"]{
  89.             throw new Services_Yahoo_Exception("Parameter xmlsrc must be defined");
  90.         }
  91.         $url = self::REQUEST_URL . "?appid=" 
  92.                $this->parameters["appid"
  93.                "&xmlsrc=" $this->parameters["xmlsrc"];
  94.         return ($urlencodeurlencode($url$url;
  95.     }
  96.     
  97.     /**
  98.      * Sets the Yahoo! Application ID to use for this request
  99.      *
  100.      * @return void 
  101.      * @access public
  102.      */
  103.     public function setAppID($id)
  104.     {
  105.         $this->parameters["appid"$id;
  106.     }
  107.     
  108.     /**
  109.      * Sets the XML for this request
  110.      *
  111.      * @return void 
  112.      * @access public
  113.      */
  114.     public function setXMLSrc($xmlSrc)
  115.     {
  116.         $this->parameters["xmlsrc"$xmlSrc;
  117.     }
  118. }
  119.  
  120. /*
  121.  * Local variables:
  122.  * tab-width: 4
  123.  * c-basic-offset: 4
  124.  * c-hanging-comment-ender-p: nil
  125.  * End:
  126.  */

Documentation generated on Fri, 20 Apr 2007 14:30:06 -0400 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.