2017 © Pedro Peláez
 

library soundcloudfetcher

Simple PHP Wrapper for Soundcloud API

image

domlip94/soundcloudfetcher

Simple PHP Wrapper for Soundcloud API

  • Monday, May 14, 2018
  • by DomLip94
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Simple SoundCloud API Wrapper

Get started

The quickest way to get going is by using Composer (it's 2019)., (*1)

Do so by executing the command below in your cli:, (*2)

composer require domlip94/soundcloudfetcher

To use, firstly we instantiate the class, (*3)

$soundCloud = new SoundCloud([
    'client_id'     => null,
    'client_secret' => null
]);

The client_secret is not usually required, but client_id is., (*4)

Available Methods

At the minute the only available methods are resolve and fetch track data, I intend to add more methods soon., (*5)

Alternatively, you can call an undefined API method yourself (see below.), (*6)

Resolve a Soundcloud URL

This resolves a SoundCloud URL to a track ID as an integer, which you may need for other API calls., (*7)

It is called like so:, (*8)

$soundCloud->resolveSoundCloudUrl(TRACK_URL);

The TRACK_URL argument would obviously be the link to the track, like below., (*9)

$soundCloud->resolveSoundCloudUrl('https://soundcloud.com/adamstuartfunston/af-podcast-014');

$soundCloud->resolveSoundCloudUrl($trackUrl);

This then returns, (*10)

(int) 649287689

Get track data

This returns the track data as an array., (*11)

You can either choose certain array keys to return, or return everything., (*12)

It is called like so:, (*13)

$soundCloud->fetchTrackData(TRACK_URL, ARRAY_KEYS_TO_RETURN);
  • ARRAY_KEYS_TO_RETURN must be an array or null.

So an example would be,, (*14)

Get all track data
$soundCloud->fetchTrackData('https://soundcloud.com/adamstuartfunston/af-podcast-014');
Get track length
$soundCloud->fetchTrackData('https://soundcloud.com/adamstuartfunston/af-podcast-014', [
    'duration'
]);
Get track title and length
$soundCloud->fetchTrackData('https://soundcloud.com/adamstuartfunston/af-podcast-014', [
    'title', duration'
]);

Other methods

While I build this out, only the basics are available. However, the two methods above call the same method to execute their call., (*15)

That method is:, (*16)

$soundCloud->doApiCall(API_METHOD, METHOD_ARGUMENTS);
  • API_METHOD is the remote API method endpoint.
  • METHOD_ARGUMENTS is an array of arguments we will provide to the SoundCloud API.

The Versions

14/05 2018

dev-master

9999999-dev https://github.com/DomLip94/SoundCloudFetcher

Simple PHP Wrapper for Soundcloud API

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

api php soundcloud music