Open-source project
njasm/soundcloud avatar
njasm/soundcloud

njasm/soundcloud: A PHP 5.6 Wrapper for the SoundCloud API

Soundcloud.com API wrapper written in PHP with OAuth2 support.

100 stars23 forksPHPLicense varies

At a glance

What is it?
njasm/soundcloud is a small PHP library that wraps SoundCloud's OAuth2 flows and REST resources. It targets legacy PHP 5.6 applications, but its maintenance status is unclear.
Who is it for?
Adopt njasm/soundcloud if you maintain a PHP 5.6 codebase that needs direct SoundCloud API access without a heavy HTTP client. Do not adopt it for new projects on PHP 7.4 or PHP 8, where the official SoundCloud API docs and modern HTTP clients like Guzzle offer clearer paths.
Can I use it commercially?
Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
Is it still maintained?
Probably not. The repository last received commits 24 months ago, on October 14, 2024.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • njasm/soundcloud100 ★ · +0
Star history
Repository2026-08-182026-10-15
njasm/soundcloud100100

0 Stars in the last 58 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What This Wrapper Solves and Who Needs It

SoundCloud's API requires OAuth2 authorization, token exchange, and signed requests. Doing that by hand with cURL is repetitive and error prone. njasm/soundcloud packages those steps into a PHP class. Its target user is a developer running PHP 5.6 or higher who wants to build a SoundCloud integration without writing the OAuth dance from scratch. The README mentions both a facade class and a lower-level Soundcloud class. The facade handles the boilerplate for authorization URLs and token exchange. The plain class gives you direct control over request parameters. If you run a legacy application that still sits on PHP 5.6, this library matches that environment. Newer PHP versions are not the focus. The project also serves someone who needs to upload or download media files, because the wrapper includes dedicated methods for those operations. The README does not list any other dependencies beyond PHP itself, which keeps the install footprint small.

The OAuth2 Flow Is the Core Mechanism

The library implements two authentication paths. The first is the standard authorization code flow. You create a SoundcloudFacade with a client ID, client secret, and callback URI. The getAuthUrl() method produces the URL where you send the user. After the user returns with a code, you call codeForToken($code). The second path is the user credentials flow. You pass a username and password directly to userCredentials(). The README states that on success the access token is automatically set for subsequent requests. That means you do not have to store the token manually. The Response object is always returned, so you can inspect the body. This design centralizes the token handling inside the wrapper. The trade-off is that you cannot easily plug in your own token storage or refresh logic. The library assumes the token stays valid for the session. SoundCloud access tokens expire, and the README does not describe a refresh mechanism. That is a gap you need to account for if you plan long-running integrations.

Request Building and the request() Method

The library separates resource definition from the actual HTTP call. You chain methods like get('/tracks') or post('/playlists', $data) and then invoke request() to send it. The README gives an example where you call $soundcloud->get('/resolve', ['url' => 'http://www.soundcloud.com/hybrid-species']) and then $response = $soundcloud->request(). This two-step pattern lets you set parameters either as an array argument or via setParams(). It also means you can prepare a request and decide later when to fire it. Some operations like userCredentials() and download() call request() automatically, which the README notes explicitly. This inconsistency can trip you up if you expect every method to defer the network call. The Response object offers three body accessors: bodyRaw() for the string, bodyObject() for a decoded object, and bodyArray() for an array. The README also mentions getCurlResponse() to retrieve the last cURL response object. That method is useful for debugging but also reveals that the library is tightly coupled to cURL. You cannot swap in a different HTTP transport.

Installation and Configuration Are Straightforward

The recommended install path is Composer. The README shows adding "njasm/soundcloud": "dev-master" to your composer.json. That version string is a red flag: dev-master means you depend on the default branch, not a tagged release. The repository listing does not show any recent releases, so you may be pulling unreleased code. If you avoid Composer, the library ships an autoload.php file in src/Soundcloud/. You include that file and the classes become available. The usage examples all start with use Njasm\Soundcloud\SoundcloudFacade; or use Njasm\Soundcloud\Soundcloud;. There is no configuration file or environment variable setup. You pass credentials directly to the constructor. For the facade, that is $clientID, $clientSecret, and $callbackUri. For the plain Soundcloud class, the README shows only two arguments: $clientID and $clientSecret. The callback URI is only needed for the authorization code flow. This simplicity is a plus, but it also means you must manage secrets in your own code. The README does not mention environment variables or config files.

File Upload and Download Have Specific Behavior

The upload method expects a file path and a data array. The README shows two styles for the data array. One uses keys like 'title' and 'downloadable'. The other uses old-school SoundCloud keys like 'track[title]' and 'track[downloadable]'. Both work. For artwork, you pass a \CURLFile object. The download method is more interesting. By default, download($trackID) does not fetch the file into memory. Instead it returns a response with a Location header. Your code must read that header and redirect the user. The README even shows a typo in the header call: header('Loacation: ' . ...). That typo is in the documentation, not necessarily in the code. If you pass true as the second argument to download(), the library fetches the track content into memory. The README warns that this is a caution case because large files can exhaust server memory. You then use file_put_contents() to save it. This design gives you a choice between a lightweight redirect and a server-side download. The in-memory option is only suitable for small files, and the documentation does not specify a size limit.

Limitations: XML Support Is a Dead End

The README contains a blunt note about XML. SoundCloud stopped sending XML responses. The asXml() method still exists in version 2.x, but calling it has no effect. Every request sends an Accept header of application/json. This is a real limitation if you have legacy code that expects XML. The library keeps the method for backward compatibility, but it is a no-op. You should not rely on it. Another limitation is the PHP version floor. PHP 5.6 is end-of-life since 2018. The library does not mention PHP 7 or PHP 8 support. If you run a modern PHP stack, this wrapper may still work, but it is not tested or documented for it. The README does not list any security considerations, such as how tokens are stored or whether SSL verification is enforced. The absence of that information is a gap. You must inspect the source to know if it verifies certificates. The project also has no stated license. The repository metadata says license unknown. That is a legal problem if you plan to use it in a commercial product. You cannot assume it is open source without a license file.

Alternatives: Official SDKs and Modern HTTP Clients

The most direct alternative is to use SoundCloud's official API documentation and a general HTTP client like Guzzle. Guzzle is a mature PHP library with active maintenance, PSR-7 support, and middleware. You would write the OAuth2 flow yourself, but you get full control over token refresh and error handling. The official SoundCloud API also provides SDKs for other languages, but not a first-party PHP SDK as far as the material shows. Another alternative is the soundcloud/soundcloud-php package, which exists on Packagist but is not covered here. The key difference in approach is that njasm/soundcloud is a thin wrapper that hides cURL details. Guzzle gives you a richer ecosystem, including asynchronous requests and plugins. If you need to integrate with other APIs beyond SoundCloud, Guzzle is a better foundation. If you only need SoundCloud and want minimal code, this wrapper is simpler. But the lack of a license and the dev-master dependency make it a riskier choice for production.

Maintenance and Upgrade Cost

The repository metadata shows no recent releases and no last push date. The README references version 2.x.x, but there is no tagged release in the provided material. This suggests the project may be in maintenance mode or abandoned. The upgrade cost is low if you only use the facade methods, because the API surface is small. However, you must consider that SoundCloud may change its API endpoints or authentication flows. The wrapper will not update itself. You will need to fork it or patch it if SoundCloud breaks something. The README does not mention any testing or CI setup beyond a Scrutinizer badge. There is no changelog. The composer requirement of dev-master means you are always on the latest commit, which could introduce breaking changes without warning. For a production system, you should pin a specific commit hash or fork the repository. The license issue compounds this: without a license, you may not have the legal right to fork and modify it. Verify the license before you rely on it.

Editorial conclusion

Adopt njasm/soundcloud if you maintain a PHP 5.6 codebase that needs direct SoundCloud API access without a heavy HTTP client. Do not adopt it for new projects on PHP 7.4 or PHP 8, where the official SoundCloud API docs and modern HTTP clients like Guzzle offer clearer paths. Before using it, verify the SoundCloud API endpoints still match the wrapper's resource paths, check the composer package's actual version tag (the README suggests dev-master), and confirm the license, which the repository does not state. The library's value is its facade for OAuth2 and file upload, but you must accept its uncertain future and limited documentation.

Frequently asked questions

What does the njasm/soundcloud library do?

It wraps the SoundCloud API in PHP. The implemented features are user authorization and authentication, authentication with the user credentials flow, access to all GET, PUT, POST and DELETE resources, and media file download and upload.

Which authentication flows does njasm/soundcloud support?

Two. A web flow where you build an authorization URL with response type, scope and state, then exchange the returned code for a token, and a user credentials flow that takes a username and password, sets the returned access token automatically for later requests, and still hands back a response object.

Does asXml() still work in njasm/soundcloud?

No. The README states that SoundCloud stopped sending responses in XML, that the methods are kept in the 2.x.x versions, and that calling them has no effect on the request because all requests carry an accept header of application/json.

How does njasm/soundcloud handle file downloads?

With one argument the download returns a response whose location header you forward so the browser fetches the file itself. With a second argument the file is fetched into an in-memory variable in your server, which the documentation flags with a caution, and you then write it to disk yourself.

What PHP version does njasm/soundcloud require?

PHP 5.6 or higher. Installation is recommended through composer with a dev-master constraint, and if you do not use composer the library ships an autoload file in its source directory that you include instead.

Official sources

  1. Official README
  2. Project repository
  3. README
  4. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/njasm-soundcloud.svg)](https://hysenlabs.com/projects/njasm-soundcloud)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/njasm-soundcloud.svg)](https://hysenlabs.com/projects/njasm-soundcloud)