Get support for KnpLabs/php-lastfm-client

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

KnpLabs/php-lastfm-client

Not actively maintained

This project is not actively maintained by KnpLabs. Please contact us if you would like to take over.

PHP Last.fm API

A PHP (5.3+) client library for the Last.fm API.

Quick start

The main entry point of the library is the Lastfm\Client class. Once you have a Client instance, you can easily access all the API services and call their methods.

Let's try to find a track using the search method of the track service:

<?php

$client = new Lastfm\Client('MyApiKey');

$tracks = $client->getTrackService()->search(array(
    'track' => 'No cars go'
));

foreach ($tracks as $track) {
    echo $track['name'];
}

The API Key

All the API methods require you to specify an api_key parameter. Luckily, the client is smart enough to add it automatically to all your API calls. To turn this functionality on, you simply need to configure the client's API key by either providing it as first argument of the constructor or setting it after using the ->setApiKey() method.

<?php

$client = new Lastfm\Client('MyApiKeyABC123');

The Method Signature

Some of the API methods requires you to add a method signature to their calls. Fortunately, the Client will automatically create it and add it to the request when needed. Prior to use such methods, you must define the client's API shared secret. To do that, you can either specify the secret as second argument of the client's constructor or set it using the ->setSecret() method.

<?php

$client = new Lastfm\Client('MyApiKeyABC123', 'TheSecretXxx');

The Session

The session is used to authenticate the client on the Last.fm API. I will not explain all the Last.fm authentication mechanisms here. The only thing you must to know is that some methods requires the client to be authenticated. Prior to use such methods, you must define the client's session by either passing it as third argument of the constructor or setting it using the ->setSession() method.

<?php

$session = new Lastfm\Session('John', 'TheSessionKey');
$client = new Lastfm\Client('MyApiKey', 'TheSecret', $session);
Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2