【问题标题】:Soundcloud API - retrieving users followers in a particular orderSoundcloud API - 按特定顺序检索用户关注者
【发布时间】:2016-05-10 21:51:57
【问题描述】:

最近我有了一个想法,为自己的目的制作一个应该使用 SoundCloud API 的 Chrome 扩展。但是我发现 API 的功能非常有限,或者我需要的那些功能可能没有记录/我只是没有找到答案。 例如,首先我想按特定顺序检索一些用户关注者。为了澄清,响应应该按followers_count -> 降序排序。因此,响应中的第一个追随者应该是我们提出请求的用户的所有追随者周围拥有最大追随者数量的追随者。等等。 经过大量搜索@google后,我发现了一个旧线程,其中一个人询问了类似的功能,并且来自 SC 支持的人告诉他在请求中使用“&order=value”,效果很好,但已被弃用且无法正常工作现在。 我想知道此时是否可行,如果不可行 - 我们可以期待很快添加此功能吗?我相信这根本不是一件复杂的事情。

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

【问题讨论】:

    标签: javascript api google-chrome soundcloud


    【解决方案1】:

    假设您想从 Souncloud 中按降序检索用户关注者。

    假设我们有五个拥有 Sound-Cloud 个人资料 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 包含您需要的信息。

    【讨论】:

      猜你喜欢
      • 2017-10-23
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 2021-03-01
      相关资源
      最近更新 更多