PHP code example of danae / soundcloud-php

1. Go to this page and download the library: Download danae/soundcloud-php 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/ */

    

danae / soundcloud-php example snippets




// Create the client
$soundcloud = new Danae\Soundcloud\Soundcloud([
  'client_id' => '<client id>',
  'client_secret' => '<client secret>',
  'redirect_url' => '<redirect url>'
]);

// Authorize the client with an authorization code
$soundcloud->authorizeWithCode('<authorization code>');

// Get the tracks of the authenticated user
$tracks = $soundcloud->get('/me/tracks');

$soundcloud = new Danae\Soundcloud\Soundcloud([
  'client_id' => '<client id>',
  'client_secret' => '<client secret>'
]);

// Using an authorization code
$soundcloud->authorizeWithCode('<authorization code>');

// Using client credentials provided via the constructor
$soundcloud->authorizeWithClientCredentials();

// Using a refresh token
$soundcloud->authorizeWithRefreshToken('<refresh token>');

$accessToken = $soundcloud->accessToken;

$soundcloud = new Danae\Soundcloud\Soundcloud([
  'client_id' => '<client id>',
  'client_secret' => '<client secret>',
  'redirect_url' => '<redirect url>'
]);

$soundcloud->authorizeWithCode('<authorization code>');

$soundcloud = new Danae\Soundcloud\Soundcloud([
  'client_id' => '<client id>',
  'client_secret' => '<client secret>'
]);

$soundcloud->authorizeWithClientCredentials();

$soundcloud = new Danae\Soundcloud\Soundcloud([
  'client_id' => '<client id>',
  'client_secret' => '<client secret>',
  'redirect_url' => '<redirect url>'
]);

$soundcloud->authorizeWithRefreshToken('<refresh_token>');

// Send a request to one of the API endpoints
$soundcloud->get($uri, array $query = []);
$soundcloud->post($uri, array $body = [], array $query = []);
$soundcloud->put($uri, array $body[], array $query = []);
$soundcloud->delete($uri, array $query = []);

// Resolve a SoundCloud URL to an API endpoint
$soundcloud->resolve($url, array $query = []);

// Send an oembed request to the API
$soundcloud->oembed($url, array $query = []);
shell
$ composer 
json
"anae/soundcloud-php": "^3.0"
}