Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
oauth.php
Aller à la documentation de ce fichier.
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  */
20 {
21  /**
22  * Options for the JOpenstreetmapOauth object.
23  *
24  * @var JRegistry
25  * @since 13.1
26  */
27  protected $options;
28 
29  /**
30  * Constructor.
31  *
32  * @param JRegistry $options JOpenstreetmapOauth options object.
33  * @param JHttp $client The HTTP client object.
34  * @param JInput $input The input object
35  *
36  * @since 13.1
37  */
38  public function __construct(JRegistry $options = null, JHttp $client = null, JInput $input = null)
39  {
40  $this->options = isset($options) ? $options : new JRegistry;
41 
42  $this->options->def('accessTokenURL', 'http://www.openstreetmap.org/oauth/access_token');
43  $this->options->def('authoriseURL', 'http://www.openstreetmap.org/oauth/authorize');
44  $this->options->def('requestTokenURL', 'http://www.openstreetmap.org/oauth/request_token');
45 
46  /*
47  $this->options->def('accessTokenURL', 'http://api06.dev.openstreetmap.org/oauth/access_token');
48  $this->options->def('authoriseURL', 'http://api06.dev.openstreetmap.org/oauth/authorize');
49  $this->options->def('requestTokenURL', 'http://api06.dev.openstreetmap.org/oauth/request_token');
50  */
51 
52  // Call the JOauth1Client constructor to setup the object.
53  parent::__construct($this->options, $client, $input, null, '1.0');
54  }
55 
56  /**
57  * Method to verify if the access token is valid by making a request to an API endpoint.
58  *
59  * @return boolean Returns true if the access token is valid and false otherwise.
60  *
61  * @since 13.1
62  */
63  public function verifyCredentials()
64  {
65  return true;
66  }
67 
68  /**
69  * Method to validate a response.
70  *
71  * @param string $url The request URL.
72  * @param JHttpResponse $response The response to validate.
73  *
74  * @return void
75  *
76  * @since 13.1
77  * @throws DomainException
78  */
79  public function validateResponse($url, $response)
80  {
81  if ($response->code != 200)
82  {
83  $error = htmlspecialchars($response->body);
84 
85  throw new DomainException($error, $response->code);
86  }
87  }
88 }