Appel d'une API web avec paramètres
Bonjour,
Je n'arrive pas à appeler mon API web (en PHP) avec des paramètres.
Si je fais l'appel à la main dans mon navigateur :
- sans paramètre : OK http://cerbourg.free.fr/volleyscore/api/test.php
- avec paramètre : OK http://cerbourg.free.fr/volleyscore/...?monparam=toto
Si je fais l'appel par mon code javascript :
- sans paramètre : OK http://cerbourg.free.fr/volleyscore/...ans_param.html
- avec paramètre : KO ! http://cerbourg.free.fr/volleyscore/...vec_param.html
Un truc tout con doit m'échapper, mais je ne vois pas lequel... Merci pour toute aide !
Au cas où, mon php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
<?php
if (isset($_GET['monparam'])) {
response('OK monparam = '.$_GET['monparam']);
} else {
response('pas de monparam');
}
function response($s){
$response['url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$response['reponse'] = $s;
$json_response = json_encode($response);
echo $json_response;
}
?> |