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.

50 lines
1.6 KiB

3 years ago
<?php
header("Content-type: text/plain;charset=utf-8");
// 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);