PHP code example of ise / php-soundcloud
1. Go to this page and download the library: Download ise/php-soundcloud library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ise / php-soundcloud example snippets php
try {
$response = json_decode($soundcloud->get('me'), true);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
php
$comment = <<<EOH
<comment>
<body>Yeah!</body>
</comment>
EOH;
try {
$response = json_decode(
$soundcloud->post(
'tracks/1/comments',
$comment,
array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))
),
true
);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
php
$track = <<<EOH
<track>
<downloadable>true</downloadable>
</track>
EOH;
try {
$response = json_decode(
$soundcloud->put(
'tracks/1',
$track,
array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))
),
true
);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
php
try {
$response = json_decode($soundcloud->delete('tracks/1'), true);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
php
$track = array(
'track[title]' => 'My awesome track',
'track[tags]' => 'dubstep rofl',
'track[asset_data]' => '@/absolute/path/to/track.mp3'
);
try {
$response = $soundcloud->post('tracks', $track);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
php
try {
$track = $soundcloud->download(1337);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
// do something clever with $track. Save to file perhaps?
php
$playlistId = 2000;
$trackIds = array(2001);
$optionalFields = array('title' => 'My awesome playlist');
try {
$playlist = $soundcloud->updatePlaylist($playlistId, $trackIds, $optionalFields);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}