Souncloudから降順でユーザーフォロワーを取得するとします。
我々はサウンド・クラウドのプロフィールのURLを持つ5人のユーザー
- https://soundcloud.com/drop-the-bassline
- https://soundcloud.com/certifiedjackin
- https://soundcloud.com/ravingkoko
- https://soundcloud.com/twenty4sevenedm
- 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
は、情報が含まれています。