2016-05-03 14 views
0

最近SoundCloud APIを使用する必要がある独自の目的でChrome拡張機能を作成する方法があります。しかし、私は、APIの機能が非常に限られているか、必要と思われる機能が文書化されていないこと、あるいは答えが見つからなかったことが分かりました。 たとえば、特定の順序でいくつかのユーザーのフォロワーを取得したいと考えています。明確にするには、followers_count - > descendingで応答をソートする必要があります。応答の最初のフォロワーは、私たちが要求したユーザーの全フォロワーの周りにフォロワーの最大数を持つフォロワーでなければなりません。等々。 多くの検索の後、私は古いスレッドを発見しました。そこでは、男がSCのサポートから「&オーダー=値」を使用するように頼まれました。要求にはうまくいきましたが、非推奨です。今は働いていない。 この瞬間にそれが可能かどうかを知りたいのですが、そうでない場合はすぐにこの機能を追加することができますか?私はこれが複雑なことではないと信じています。Soundcloud API - 特定の順序でユーザーフォローを取得する

私が必要とするのは、followers_countというユーザーを特定の順序で取得することです。それが最初の質問です。ここで成功すれば、さらに深くなるでしょう。先にありがとう。どんな助けも高く評価されます。

答えて

0

Souncloudから降順でユーザーフォロワーを取得するとします。

我々はサウンド・クラウドのプロフィールのURLを持つ5人のユーザー

  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
があるとしましょうあなたが必要として10

コード

// 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は、情報が含まれています。

関連する問題