Source for file oauth.php

Documentation is available at oauth.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Openstreetmap
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die();
  11.  
  12. /**
  13.  * Joomla Platform class for generating Openstreetmap API access token.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Openstreetmap
  17.  * @since       13.1
  18.  */
  19. {
  20.     /**
  21.      * Options for the JOpenstreetmapOauth object.
  22.      *
  23.      * @var    JRegistry 
  24.      * @since  13.1
  25.      */
  26.     protected $options;
  27.  
  28.     /**
  29.      * Constructor.
  30.      *
  31.      * @param   JRegistry  $options  JOpenstreetmapOauth options object.
  32.      * @param   JHttp      $client   The HTTP client object.
  33.      * @param   JInput     $input    The input object
  34.      *
  35.      * @since   13.1
  36.      */
  37.     public function __construct(JRegistry $options nullJHttp $client nullJInput $input null)
  38.     {
  39.         $this->options = isset($options$options new JRegistry;
  40.  
  41.         $this->options->def('accessTokenURL''http://www.openstreetmap.org/oauth/access_token');
  42.         $this->options->def('authoriseURL''http://www.openstreetmap.org/oauth/authorize');
  43.         $this->options->def('requestTokenURL''http://www.openstreetmap.org/oauth/request_token');
  44.  
  45.         /*
  46.         $this->options->def('accessTokenURL', 'http://api06.dev.openstreetmap.org/oauth/access_token');
  47.         $this->options->def('authoriseURL', 'http://api06.dev.openstreetmap.org/oauth/authorize');
  48.         $this->options->def('requestTokenURL', 'http://api06.dev.openstreetmap.org/oauth/request_token');
  49.         */
  50.  
  51.         // Call the JOauth1Client constructor to setup the object.
  52.         parent::__construct($this->options$client$inputnull'1.0');
  53.     }
  54.  
  55.     /**
  56.      * Method to verify if the access token is valid by making a request to an API endpoint.
  57.      *
  58.      * @return  boolean  Returns true if the access token is valid and false otherwise.
  59.      *
  60.      * @since   13.1
  61.      */
  62.     public function verifyCredentials()
  63.     {
  64.         return true;
  65.     }
  66.  
  67.     /**
  68.      * Method to validate a response.
  69.      *
  70.      * @param   string         $url       The request URL.
  71.      * @param   JHttpResponse  $response  The response to validate.
  72.      *
  73.      * @return  void 
  74.      *
  75.      * @since   13.1
  76.      * @throws  DomainException
  77.      */
  78.     public function validateResponse($url$response)
  79.     {
  80.         if ($response->code != 200)
  81.         {
  82.             $error htmlspecialchars($response->body);
  83.  
  84.             throw new DomainException($error$response->code);
  85.         }
  86.     }
  87. }

Documentation generated on Tue, 19 Nov 2013 15:09:41 +0100 by phpDocumentor 1.4.3