From 434326752a3edb273eb9abfccd905167812e5695 Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 21 Feb 2022 12:00:38 +0100 Subject: [PATCH] php cors et curl --- b3-dev/api/api-php-call/CORS/index.php | 52 +++++++++++++++++++++++++++++++++ b3-dev/api/api-php-call/calls/index.php | 50 +++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 b3-dev/api/api-php-call/CORS/index.php create mode 100644 b3-dev/api/api-php-call/calls/index.php diff --git a/b3-dev/api/api-php-call/CORS/index.php b/b3-dev/api/api-php-call/CORS/index.php new file mode 100644 index 0000000..cdfb68a --- /dev/null +++ b/b3-dev/api/api-php-call/CORS/index.php @@ -0,0 +1,52 @@ + + + + + + jQuery Query + + + + + + + +
+
+    Header set Content-Security-Policy \
+        " \
+        script-src 'unsafe-eval' 'unsafe-inline' 'self' ssl.google-analytics.com www.google-analytics.com ajax.googleapis.com www.googletagmanager.com tarteaucitron.io www.tarteaucitron.io; \
+        default-src 'none'; \
+        connect-src 'self'; \
+        img-src 'self' 'unsafe-inline' data: ssl.google-analytics.com www.google-analytics.com ajax.googleapis.com www.googletagmanager.com tarteaucitron.io www.tarteaucitron.io; \
+        style-src 'self' 'unsafe-inline' ssl.google-analytics.com tarteaucitron.io www.tarteaucitron.io; \
+        base-uri 'self'; \
+        font-src 'self' data:; \
+        "
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/b3-dev/api/api-php-call/calls/index.php b/b3-dev/api/api-php-call/calls/index.php new file mode 100644 index 0000000..fe48c47 --- /dev/null +++ b/b3-dev/api/api-php-call/calls/index.php @@ -0,0 +1,50 @@ +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); \ No newline at end of file