You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
62 lines
2.0 KiB
<?php
|
|
header("Content-type: text/plain;charset=utf-8");
|
|
|
|
|
|
// curl :
|
|
// https://www.php.net/manual/fr/intro.curl.php
|
|
// curl basics
|
|
// https://weichie.com/blog/curl-api-calls-with-php/
|
|
// curl basics with auth
|
|
// https://weichie.com/blog/php-curl-api-calls-authentication/
|
|
// curl en fr
|
|
// https://analyse-innovation-solution.fr/publication/fr/php/curl-post-get-proxy-https
|
|
// guide du dévbutant
|
|
// https://rapidapi.com/blog/how-to-use-an-api-with-php/
|
|
|
|
|
|
// vars
|
|
$api_key = "bc1e13327f7f4876902d4bc45c30e102";
|
|
$api_url = "https://api.geoapify.com/v1/";
|
|
$geocode_pattern = "geocode/search?text=%address%&apiKey=".$api_key;
|
|
|
|
|
|
$geocode_request = str_replace(
|
|
"%address%",
|
|
urlencode("12 rue Maupertuit, Bruz"),
|
|
$geocode_pattern);
|
|
|
|
echo "\n".$api_url.$geocode_request;
|
|
|
|
$curl = curl_init($api_url.$geocode_request);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
$response_json = curl_exec($curl);
|
|
//print_r($response_json);
|
|
$response_php = json_decode($response_json);
|
|
print_r($response_php->features[0]->geometry->coordinates);
|
|
curl_close($curl);
|
|
|
|
|
|
$curl = curl_init();
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
// curl_setopt($curl, CURLOPT_POST, 1);
|
|
// curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
|
$data['grant_type'] = 'client_credentials';
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
|
curl_setopt($curl, CURLOPT_URL, 'https://accounts.spotify.com/api/token');
|
|
|
|
$headers = array(
|
|
'Authorization' => `Basic 1111111111111111111111111111111111`,
|
|
'Content-Type' => 'application/x-www-form-urlencoded'
|
|
);
|
|
|
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
$response_json = curl_exec($curl);
|
|
print_r($response_json);
|
|
//$response_php = json_decode($response_json);
|
|
//print_r($response_php->features[0]->geometry->coordinates);
|
|
curl_close($curl); |