[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins / spip_piwik / inc / piwik_recuperer_data.php
1 <?php
2
3 if (!defined('_ECRIRE_INC_VERSION')) {
4 return;
5 }
6
7 /**
8 * Fonction de communication avec l'API REST du serveur Piwik
9 *
10 * @param string $piwik_url Url du serveur
11 * @param string $token_auth Le token d'autentification du serveur
12 * @param string $module [optional]
13 * @param string $method
14 * @param string $format [optional]
15 * @param array $options [optional]
16 * @return string Le contenu de la réponse
17 */
18 function inc_piwik_recuperer_data_dist($piwik_url, $token_auth, $module = 'API', $method, $format = 'PHP', $options = array()) {
19 $url = parametre_url($piwik_url, 'token_auth', $token_auth);
20 $url = parametre_url($url, 'module', 'API', '&');
21 $url = parametre_url($url, 'format', $format, '&');
22 $url = parametre_url($url, 'method', $method, '&');
23 if (is_array($options)) {
24 foreach ($options as $cle => $val) {
25 $url = parametre_url($url, $cle, $val, '&');
26 }
27 }
28
29 include_spip('inc/distant');
30 $content = recuperer_page($url);
31
32 return $content;
33 }