【问题标题】:Soundcloud trackID by track URL addressSoundcloud trackID by track URL 地址
【发布时间】:2019-08-30 17:02:28
【问题描述】:

我想将 soundcloud 小部件添加到我的应用程序中。 为此,我需要在 iframe src 上发送参数。 问题是 soundcloud 需要 TrackID 而不是轨道的 URL 地址,我的用户将无法在 Soundcloud 的 UI 上找到这个 trackID。 如何通过跟踪 URL 地址解析 TrackID?

如果只能通过使用 API 来实现 - 那么如何注册为新应用?现在看来不可能了。我还需要调用什么 API 来解析这些信息?

谢谢。

【问题讨论】:

标签: soundcloud


【解决方案1】:

很遗憾,SoundCloud API 无限期不接受新注册。就像上面的评论一样,一个简单的替代解决方案是,如果您使用此 URL,它将为您提供一个宽/短播放器:

https://w.soundcloud.com/player/?url=+曲目网址

示例:https://w.soundcloud.com/player/?url=https://soundcloud.com/chrisbjerken/you-still-have-my-heart

这适用于单个曲目或播放列表。

【讨论】:

    【解决方案2】:

    和你一样,我需要从 soundcloud url 获取一些曲目信息,但是我不能选择使用 API(API 自 2017 年起关闭)。这就是我想出的获取曲目 ID 的方法。

    <?php
    // url test example
    $url = "https://soundcloud.com/the-bugle/bugle-179-playas-gon-play";
    
    // this link give some infos of the track
    $infos_music_soundcloud = 'https://soundcloud.com/oembed?url='.urlencode($url).'&format=json';
    
    $page_content = file_get_contents($infos_music_soundcloud);
    if(!empty($page_content)){
        $content = json_decode($page_content);
        // now, the track ID is in the html iframe code. Lets get it.
        $matches = array();
        preg_match('/tracks%2F(.*?)&/s', $content->{'html'}, $matches);
        echo "the track id is ".$matches[1];
    }else{
        echo "the track don't seems to exists. Please verify the link";
    }
    ?>
    

    您还可以获得曲目标题、描述、缩略图、作者姓名/网址... 希望对您有所帮助;)

    编辑 - 如果曲目是私有的,请确保您提供私有链接(即末尾带有“/s-clUrZ”之类的内容)

    【讨论】:

      【解决方案3】:

      Soundcloud 有一个 API,可以调用它来解析 URL。

      如果您有一个有效的client_id,您可以执行一个GET 请求,将url 和您的client_id 设置为参数。

      https://api.soundcloud.com/resolve.json?url=https://soundcloud.com/tomer-maizner/forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner&client_id=CLIENT_ID
      

      这会给你这个响应:

      {
      kind: "track",
      id: 460976748,
      created_at: "2018/06/20 16:25:14 +0000",
      user_id: 8504856,
      duration: 3570385,
      commentable: true,
      state: "finished",
      original_content_size: 142800123,
      last_modified: "2018/06/23 15:26:59 +0000",
      sharing: "public",
      tag_list: ""forever tel aviv" circuit "we party" mix pride "tel aviv"",
      permalink: "forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner",
      streamable: true,
      embeddable_by: "all",
      purchase_url: null,
      purchase_title: null,
      label_id: null,
      genre: "Electronic",
      title: "Forever Tel-Aviv - Pride 2018 Anthems (Mixed By Tomer Maizner)",
      description: "The best of the best from the pride weekend in Tel-Aviv including tracks from all Forever Tel-Aviv superstars . Sagi Kariv / Tomer Maizner / Yinon Yahel / Tommer Mizrahi / Mor Avrahami / Elad Navon / Micky Friedman Enjoy!!! Tracklist : 1. Tomer Maizner Feat. Madame Meyhem - Unbreak My Heart 2018 2. N-Trance - Set You Free (Sagi Kariv remix) 3. Maître Gims – Mi Gna (Tommer Mizrahi Remix) 4. Micky Friedman - Eshebo feat Hila Ben Saadon (Original Mix) 5. Edson Pride - Freedom (Tomer Maizner Stanga Mash) 6. Netta - Toy (Sagi Kariv extended remix) 7. Arian Grande - No Tears Left To Cry Remix (DJ Aron Remix) 8. Steven Redant - Sunshine On My Shoulders (Tommer Mizrahi Remix) 9. Mor Avrahami - Kumei (Original Mix) 10 . Sissy That B.Y.O.B (Tomer Maizner Mashup) 11. Louie Vega - Diamond Life (Elad Navon & Niv Aroya Remix) 12. Hanna Hais - Je Ne Veux Plus Etre Ta Reine (Ranz Remix) 13. I Am Free (Yinon Yahel Remix)",
      label_name: null,
      release: null,
      track_type: null,
      key_signature: null,
      isrc: null,
      video_url: null,
      bpm: null,
      release_year: null,
      release_month: null,
      release_day: null,
      original_format: "mp3",
      license: "all-rights-reserved",
      uri: "https://api.soundcloud.com/tracks/460976748",
      user: {
      id: 8504856,
      kind: "user",
      permalink: "tomer-maizner",
      username: "TOMER MAIZNER",
      last_modified: "2018/06/20 17:34:39 +0000",
      uri: "https://api.soundcloud.com/users/8504856",
      permalink_url: "http://soundcloud.com/tomer-maizner",
      avatar_url: "https://i1.sndcdn.com/avatars-000234677748-voqr8o-large.jpg"
      },
      permalink_url: "https://soundcloud.com/tomer-maizner/forever-tel-aviv-pride-2018-anthems-mixed-by-tomer-maizner",
      artwork_url: "https://i1.sndcdn.com/artworks-000363076815-gwll9g-large.jpg",
      stream_url: "https://api.soundcloud.com/tracks/460976748/stream",
      download_url: "https://api.soundcloud.com/tracks/460976748/download",
      playback_count: 8696,
      download_count: 0,
      favoritings_count: 792,
      reposts_count: 62,
      comment_count: 5,
      downloadable: false,
      waveform_url: "https://w1.sndcdn.com/WoEUY48eF4tR_m.png",
      attachments_uri: "https://api.soundcloud.com/tracks/460976748/attachments"
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-10
        • 1970-01-01
        • 1970-01-01
        • 2018-09-21
        • 2014-06-17
        • 2023-03-06
        相关资源
        最近更新 更多