Bagosep

Create Track

Jun 2nd, 2021
723
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require '../vendor/autoload.php';
  2. use GuzzleHttp\Client;
  3.  
  4. $token = $_SESSION['token'];
  5.  
  6. $client = new Client([
  7.     'base_uri' => 'https://api.deezer.com',
  8. ]);
  9.  
  10. $remove_id = str_replace('/id', '',$_POST['songs']);
  11. $songs = str_replace('https://www.deezer.com/track/','',$remove_id);
  12.  
  13. if($_POST["songs"])
  14. {
  15.     $response = $client->request('POST', 'playlist/'.$_POST['id'].'/tracks?access_token='.$token.'&songs='.$songs);
  16.     $track = json_decode($response->getBody());
  17.  
  18.     if(!empty($track)){
  19.         session_start();
  20.         $_SESSION['msg-success'] = "Data track berhasil ditambahkan!";
  21.         header("location: index.php?id=".$_POST['id']);
  22.     }
  23. }
RAW Paste Data