How to get track ID from URL using the SoundCloud API

前端 未结 5 2081
时光说笑
时光说笑 2020-12-24 15:02

How can I get a track ID from a track URL using the SoundCloud API?

5条回答
  •  伪装坚强ぢ
    2020-12-24 15:37

    So my final code looks like this. Thank you guys for the help to get this working.

    include_once('../Services/Soundcloud.php'); 
    $client = new Services_Soundcloud('CLIENT_ID', 'CLIENT_SECRET');
    $track_url=$_POST['trackurl'];
    $track_url=str_replace("https://soundcloud.com/USERNAME/","",$track_url);
    $track = json_decode($client->get("tracks/".$track_url));    
    $track_id=$track->id;
    echo $track_id;
    

提交回复
热议问题