From f975f4a77dd45e3caeb2ba791bd28b36aee8edc9 Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 21 Feb 2022 12:06:56 +0100 Subject: [PATCH] exemples curls des teams --- b3-dev/api/api-php-call/exemple-teams.txt | 291 ++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 b3-dev/api/api-php-call/exemple-teams.txt diff --git a/b3-dev/api/api-php-call/exemple-teams.txt b/b3-dev/api/api-php-call/exemple-teams.txt new file mode 100644 index 0000000..63aaa66 --- /dev/null +++ b/b3-dev/api/api-php-call/exemple-teams.txt @@ -0,0 +1,291 @@ +[10:43] GUILLIN David + SPACEX: +​[10:43] GUILLIN David + + +$ch =curl_init('https://api.spacexdata.com/v3/launches/60'); +// Permet de prendre la data +curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); +// Initialise le header +curl_setopt($ch,CURLOPT_HEADER,0); +// Execute en json +$response_json =curl_exec($ch); +// decode le json en tableau +$response_php =json_decode($response_json); +print_r($response_php); + +curl_close($ch); + +​[10:43] MASSÉ David + IMDB : + + + + + 'Bearer '.$token->access_token, +'Content-Type' => 'application/json', +'Accept' => 'application/json' + ); + +curl_setopt($curl, CURLOPT_VERBOSE, 1); + +curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + +$response_json = curl_exec($curl); + +if(curl_errno($curl)){​​​​​​​ +$errstr = curl_errno($curl).": ".curl_error($curl); + }​​​​​​​ +curl_close ($curl); +if(isset($errstr)){​​​​​​​ +echo$errstr; + }​​​​​​​ +print_r($response_json); +//$response_php = json_decode($response_json); +//print_r($response_php->features[0]->geometry->coordinates); +curl_close($curl); + +​[11:41] GUILLIN David + +Cors + +First enable mod_headers on your server, then you can use header directive in both Apache conf and .htaccess. + + + +enable mod_headers + + + + +a2enmod headers + + + + +configure header in .htaccess file + + +Header add Access-Control-Allow-Origin "*" +Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" +Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS" + + + +TEAM LOL + + + + + + + +Document + + + +'.'Nom : '.$value->name. +'
'.'Niveau : '.$value->level. +'
'.'Champion : '.$value->champion. +'
'.'Kill / Death / Assist : '.$value->kda. +'
'.'Résultat du match : '.$value->resultat. +'
'.'---------------------------------------' +); +} +curl_close($curl); + + + +?> + + + + + +TEAM POKEMON :: + pokemon); + + curl_close($curl2); +