Soundcloud API-按特定顺序检索用户追随者

Soundcloud API - retrieving users followers in a particular order

本文关键字:检索 用户 追随者 定顺序 API- Soundcloud      更新时间:2023-09-26

最近我有了一个想法,为自己的目的制作一个Chrome扩展,应该使用SoundCloud API。但我发现API的功能非常有限,或者我需要的功能没有文档记录/我只是没有找到答案。例如,首先我想按特定顺序检索一些用户的追随者。为了澄清这一点,响应应该按照followers_count->descending进行排序。因此,响应中的第一个关注者应该是我们请求的用户的所有关注者周围拥有最大关注者数量的关注者。等等经过大量搜索@google,我发现了一个旧帖子,其中一个人询问了类似的功能,SC支持人员告诉他在请求中使用"&order=value",这很好,但现在不推荐使用,也不起作用。我想知道目前是否有可能,如果没有,我们能期待这个功能很快被添加吗?我相信这根本不是一件复杂的事情。

简而言之,我需要的是按照特定的顺序检索任何用户followers_count。这是第一个问题。如果我们在这里取得成功,我们会走得更深。谢谢。非常感谢您的帮助。

假设您想从Souncloud中按desc顺序检索用户追随者。

假设我们有五个用户拥有声音云配置文件URL

  1. https://soundcloud.com/drop-the-bassline
  2. https://soundcloud.com/certifiedjackin
  3. https://soundcloud.com/ravingkoko
  4. https://soundcloud.com/twenty4sevenedm
  5. https://soundcloud.com/pr-gangstahouse

代码

// Need Soundcloud SDK
require_once 'Services/Soundcloud.php';
// Create Object 
$client = new Services_Soundcloud(CLIENT_ID, CLIENT_SECRET);
$result = array();
$urls = array(array
                (
                    'link' => 'https://soundcloud.com/drop-the-bassline',
                ),
             array
                (
                    'link' => 'https://soundcloud.com/certifiedjackin',
                ),
            array
                (
                    'link' => 'https://soundcloud.com/ravingkoko',
                ),
            array
                (
                    'link' => 'https://soundcloud.com/twenty4sevenedm',
                ),
            array
                (
                    'link' => 'https://soundcloud.com/pr-gangstahouse',
                )
                );
foreach($urls as $key=>$u){
    try{
         $response = json_decode($client->get('resolve', array('url' => $u['link']), array(CURLOPT_FOLLOWLOCATION => true)));
         $result[$key]['followers_count']= $response->followers_count;
    }catch(Services_Soundcloud_Invalid_Http_Response_Code_Exception $e){
         echo $e->getMessage(); 
    }
}
foreach ($result as $key => $row) {
    // replace 0 with the field's index/key
    $dates[$key]  = $row['followers_count'];
}
array_multisort($dates, SORT_DESC, $result);
//echo"<pre>";print_r($result);echo"</pre>";

$data包含您需要的信息。