Get Soundcloud URL for a track using only its ID

前端 未结 3 1768
不知归路
不知归路 2021-01-03 03:02

I\'ve inherited a database of Soundcloud IDs and would like to build a page linking to each track on Soundcloud. Is it possible to link to a track on the Soundcloud website

相关标签:
3条回答
  • 2021-01-03 03:49

    First you will need to register an app at https://soundcloud.com/you/apps.

    Then use the API to return a JSON object of the track using the track ID and your client ID.

    e.g. (using jQuery) …

    $.ajax({ url: "http://api.soundcloud.com/playlists/405726.json?client_id=XXXX", type: 'GET', success: function (data) { console.log(data); } });

    Where XXX is your Client ID.

    0 讨论(0)
  • 2021-01-03 03:54

    You can scrape it from the "widget" URL

    https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/{trackId}

    contains a link element

    <link rel="canonical" href="{canonicalURI}">
    
    0 讨论(0)
  • 2021-01-03 03:54

    It seems that the way to do this is to use the API. With a track number, you can call

    http://api.soundcloud.com/tracks/12345678.json?client_id=YOUR_CLIENT_ID
    

    This returns a JSON object with a permalink_url property which gives you the full url including the user and track name.

    See the API tracks documentation for more details.

    0 讨论(0)
提交回复
热议问题