使用API​​访问Soundcloud图表

nut*_*tzt 3 soundcloud

有没有办法使用soundcloud api 访问新图表https://soundcloud.com/charts/top(前50名)?或者还有其他方式吗?

也许用php或其他东西爬行?

Ste*_*ono 16

要找到可以与HTTP API请求一起使用的参数,您可以执行以下操作:

现在举例来说,如果你想知道参数"TOP 50 - Dance&EDM":

  • 更改过滤器框内的值
  • 检查控制台,请求以:"chart?kind ="开头
  • 在这个url里面搜索参数.

一些例子:

TOP | 舞蹈和EDM

https://api-v2.soundcloud.com/charts?kind = top&genre = soundcloud%3A generes%3A danceedm&client_id = ...

TOP | 深宅

https://api-v2.soundcloud.com/charts?kind = top&genre = soundcloud%3A genres%3A deephouse&client_id = ...

新热点

国家https://api-v2.soundcloud.com/charts?kind = 趋势和流派= soundcloud%3A 流派%3A country&client_id = ...


所有参数:

类:

  • 顶部< - 前50名
  • 趋势< - 新热点

类型:

  • 的SoundCloud:流派:所有音乐
  • 的SoundCloud:流派:所有音频
  • 的SoundCloud:流派:alternativerock
  • 的SoundCloud:类型:环境
  • 的SoundCloud:风格:古典
  • 的SoundCloud:类型:国家
  • 的SoundCloud:流派:danceedm
  • 的SoundCloud:流派:舞厅
  • 的SoundCloud:流派:deephouse
  • 的SoundCloud:流派:迪斯科
  • 的SoundCloud:流派:Drumbass二代可
  • 的SoundCloud:风格:的dubstep
  • 的SoundCloud:流派:电子
  • 的SoundCloud:流派:folksingersongwriter
  • 的SoundCloud:流派:hiphoprap
  • 的SoundCloud:类型:房子
  • 的SoundCloud:类型:独立
  • 的SoundCloud:流派:jazzblues
  • 的SoundCloud:流派:拉丁
  • 的SoundCloud:流派:金属
  • 的SoundCloud:流派:钢琴
  • 的SoundCloud:流派:流行
  • 的SoundCloud:流派:rbsoul
  • 的SoundCloud:类型:雷鬼
  • 的SoundCloud:类型:雷鬼
  • 的SoundCloud:风格:摇滚
  • 的SoundCloud:体裁:电影配乐
  • 的SoundCloud:流派:TECHNO
  • 的SoundCloud:流派:精神恍惚
  • 的SoundCloud:流派:陷阱
  • 的SoundCloud:流派:triphop
  • 的SoundCloud:流派:世界
  • 的SoundCloud:类型:有声读物
  • 的SoundCloud:风格:商务
  • 的SoundCloud:类型:喜剧
  • 的SoundCloud:类型:娱乐
  • 的SoundCloud:类型:学习
  • 的SoundCloud:流派:newspolitics
  • 的SoundCloud:流派:religionspirituality
  • 的SoundCloud:流派:科学
  • 的SoundCloud:类型:体育
  • 的SoundCloud:流派:讲故事
  • 的SoundCloud:流派:技术

php中获取TOP50的json响应的示例 - 国家/地区:

网址:https://api-v2.soundcloud.com/charts?kind = top&genre = soundcloud%3A genres%3A country&client_id = XXXXXXXXXXX&limit = 10&linked_pa​​rtitioning = 1

网址参数:
种类:热门
类型:soundcloud:流派:country
client_id:XXXXXXXXXXX
限制:10
linked_pa​​rtitioning:1

限制:您希望收到多少首歌曲作为回应.
linked_pa​​rtitioning:页码,根据限制.

例如使用Limit = 10的linked_pa​​rtitioning:

  • 1从0到9获得歌曲
  • 2从10到19获得歌曲
  • ...

例如使用Limit = 20的linked_pa​​rtitioning:

  • 1从0到19获得歌曲
  • 2从20到39获得歌曲
  • ...

现在你有了URL,如果你想用PHP进行反向JSON响应,
你必须编写例如:

<?php 
    $url = "https://api-v2.soundcloud.com/charts?kind=top&genre=soundcloud%3Agenres%3Acountry&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&limit=10&linked_partitioning=1";
    // Get JSON Response
    $json = file_get_contents($url);
    // Decode response to array
    $objectJSON = json_decode($json, true);
Run Code Online (Sandbox Code Playgroud)

示例Json响应:

{
    "genre":"soundcloud:genres:country",
    "kind":"top",
    "last_updated":"2016-03-24T09:50:02Z",
    "collection":[
        {
            "track":{
                "commentable":true,
                "comment_count":211,
                "downloadable":true,
                "download_count":80,
                "duration":251060,
                .
                .
                .
                "kind":"track",
                .
                .
                .
                .
                "license":"all-rights-reserved",
                "streamable":true,
                "title":"Award winning Falling Star",
                "uri":"https://api.soundcloud.com/tracks/245170733",
                .                
                .
                .
                "country_code":"US"
            }
            "score":1093171.0
        },
        {
            ...
        },
        OTHER TRACKS HERE...
    ],
    "query_urn":"soundcloud:charts:bc9b903f2cee44e7bca955bc2fc4601d",
    "next_href":"https://api-v2.soundcloud.com/charts?genre=soundcloud%3Agenres%3Acountry&query_urn=soundcloud%3Acharts%3Abc9b903f2cee44e7bca955bc2fc4601d&offset=20&kind=top&limit=20"
    }
}
Run Code Online (Sandbox Code Playgroud)

如果要读取响应的JSON内容:

    // Read Json taking for example Name, Title and SoundCloud URI of song.
    foreach ($objectJSON["collection"] as $key => $value) {
        echo 'user: ' . $value['track']['user']['full_name'] . "<br/>";
        echo 'title: ' . $value['track']['title'] . "<br/>";
        echo 'url: ' . $value['track']['uri'] . "<br/><br/>";
    } 
    echo $response;
?>
Run Code Online (Sandbox Code Playgroud)

这个PHP的结果:

user: ...
title: ...
url: ...

user: ...
title: ...
url: ...

...
Run Code Online (Sandbox Code Playgroud)

此代码的示例


我希望我帮助过你,对不起我的英语.

编辑:

我认为SoundCloud已经改变了获得下一页的方式.现在你需要改变"偏移"参数.

像这样:

Page 1: ....&limit=20&offset=0
Page 2: ....&limit=20&offset=20
Page 3: ....&limit=20&offset=40
Run Code Online (Sandbox Code Playgroud)

回答@VietHung问题.

问:你可以探索系统播放列表吗?(例如:soundcloud:system-playlists chart-top:all-music)

为了查找系统播放列表,我使用了Charles Web Debugging Proxy.
想法是从iOS设备(在我的例子中)嗅探由SoundClound App发送的网络包.

之后,您将Charles配置为正确嗅探SSL包,您可以将pc用作智能手机的代理.
(您必须在Windows和iOS设备上安装Charles证书才能正确嗅探SSL包,有关更多信息,请搜索google).

现在,打开SoundCloud App并单击应用程序内的每个播放列表(TOP,NEWS).截图下方(质量由油漆驱动,抱歉ahah):
SoundCloud APP

现在在查尔斯内部我们可以看到这样的事情:

Charles_Request_Soundcloud

我只将焦点设置在SoundCloud主机上,以便更好地读取传入的包.
Charles非常聪明并且将所有类似的请求放入子文件夹中,在我们的例子中,我们必须查看"system-playlist"中的所有请求.

现在,从所有请求中,您可以检索所有系统播放列表值.

我没有列出所有的播放列表歌曲,因为目前我没有太多时间.
我尽快编辑这篇文章,其中包含可能的系统播放列表的完整列表.