Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2. echo "NON FUNZIONA UN CAZZO";
  3. if (empty($_GET)) {
  4.     die("This is a redirect URI, go away!");
  5. } else {
  6.     $code = $_GET['code'];
  7.     echo $code."\n\n";
  8.     $url = 'https://accounts.spotify.com/api/token';
  9.     $data = array('grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => 'http://toastify.altervista.org/notify/redirect_uri.php');
  10.  
  11.     $ch = curl_init($url);
  12.  
  13.     //set the url, number of POST vars, POST data
  14.     $headers = array(
  15.         'Content-Type:application/x-www-form-urlencoded',
  16.         'Authorization: Basic '. base64_encode("cosemagice:woww")
  17.     );
  18.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  19.     curl_setopt($ch, CURLOPT_POST, true);
  20.     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  21.     //So that curl_exec returns the contents of the cURL; rather than echoing it
  22.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  23.  
  24.     //execute post
  25.     $result = curl_exec($ch);
  26.     var_dump($result);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement