Code Monkey home page Code Monkey logo

php-last.fm-api's People

Contributors

bhoodream avatar devilcius avatar dzantiev avatar floydian77 avatar grray avatar julianomcl avatar jwoldan avatar normanfeltz avatar peppy avatar rubencougil avatar stepri avatar webroru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-last.fm-api's Issues

Auth not working

In the examples when I want to auth I am redirected to LastFM but after this I am not redirected back to the original page like on Twitter so I stay on LastFM.

Custom callback url is missing

Notice: Undefined offset: 0 - lastfmapi/class/apibase.php (110)

I'm getting a constant error from using the libary at the moment. Could someone have a look at this? I can't find the error:

Notice: Undefined offset: 0 - lastfmapi/class/apibase.php (110);
Notice: Trying to get property of non-object - lastfmapi/class/apibase.php (111)

Dependency Injection

This is what I see :

// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$artistClass = $apiClass->getPackage($auth, 'artist', $config);
  • lastfmApi needs a dependency which is an instance of lastfmApiAuth
  • lastfmApi::getPackage always needs an instance of lastfmApiAuth

Dependency injection begins here so what I think :

  1. Create a constructor for the lastfmApi which takes as first parameter an instance of himself (yes because all classes extends him..). Share the instance in lastfmApi::$auth
  2. In lastfmApi::getPackage, remove the first parameters and at the end of this functions when packages are lazy loaded, pass $this->auth to the constructor of each package

Final result :

// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi($auth);
$artistClass = $apiClass->getPackage('artist', $config);

Do you agree ? I tested and nothing is broken.

Missing method 'getImages' in artist.php

The method is missing so I wrotten it :

/**
 * Get all images for an artist on Last.fm.
 * @param array $methodVars An array with the following values: <i>artist</i> or <i>mbid</i>
 * @return array
 */
public function getImages($methodVars) {
    $vars = array(
        'method'  => 'artist.getinfo',
        'api_key' => $this->auth->apiKey
    );
    $vars = array_merge($vars, $methodVars);

    if ( $call = $this->apiGetCall($vars) ) {
        $info['image']['small']      = (string) $call->artist->image[0];
        $info['image']['medium']     = (string) $call->artist->image[1];
        $info['image']['large']      = (string) $call->artist->image[2];
        $info['image']['extralarge'] = (string) $call->artist->image[3];
        $info['image']['mega']       = (string) $call->artist->image[4];

        return $info;
    }
    else {
        return FALSE;
    }
}

album.php getInfo() does not assign tracks to the return variable $info

Guys, please take a look at http://stackoverflow.com/questions/19618068/using-getinfo-for-album-does-not-return-tracks/21731109#21731109 and my own answer to this issue. Please implement in the future release.

I assigned the variables I needed for my code, but I think there are more (http://www.last.fm/api/show/album.getInfo) :
$i = 0;
foreach ( $call->album->tracks->track as $track ) {
$info['tracks'][$i]['name'] = (string) $track->name;
$info['tracks'][$i]['rank'] =(string)$track['rank'][0];
$info['tracks'][$i]['duration'] = (string) $track->duration;
$i++;
}

cannot manage to make it scrobble

Hi guys, and thanks for this nice library !!!

I just implemented it in my Wordpress plugin, WP Soundsystem.

Almost everything works except that I can't manage to make it scrobble.

I have the updateNowPlaying() calls working (called when track starts), it shows up on my Last.FM profile as Scrobbling now.
Then when the track has finished playing, I call scrobble().
But the track do not show up in my Last.FM library :/

Here's an example of what I set as arguments for the scrobble() function (it's a json from my debug log)

{"artist":"Ice Cube","track":"Man s Best Friend","timestamp":"1495026495897","album":null,"chosenByUser":0,"duration":"126"}

I also did try to unset chosenByUser but it does not change anything.

You can check the code here and see it in action there.

Thanks a lot !!!

Throw Exceptions instead of calling handleError()

It is a best practice in modern PHP to throw Exceptions of custom type. This way people know something's wrong in the code right away while developing/debugging code.

A big disadvantage of current implementation is that there should be such checks after every single object construction or method call:

    $auth = new AuthApi('setsession', ['apiKey' => $api_key, 'secret' => $api_secret]);

    if (empty($auth->error)) {
      $artist_api = new ArtistApi($auth);

      if (empty($artist_api->error)) {
        $artist_info = $artist_api->getInfo(['artist' => $artist]);

        if (empty($artist_api->error)) {
          return $artist_info;
        }
      }
    }

TrackApi has no 'unlove' method

And it would be great to have it !
The love method could be duplicated except that the api method should be 'track.unlove'.

'method' => 'track.unlove',

Thanks !

Error while trying to load tests

When i try to execute one of the tests (any test) i receive an error:
Example:
http://localhost/PHP-Last.fm-API-master/tests/Api/AlbumTest.php

I receive error:
( ! ) Fatal error: Class 'Tests\Api\BaseNotAuthenticatedApiTest' not found in C:\www\PHP-Last.fm-API-master\tests\Api\AlbumTest.php on line 13Call Stack#TimeMemoryFunctionLocation10.0008407528{main}( )...\AlbumTest.php:0

I did install all composer and the project dependacies, added .env file,
I did try to implement my own test like in the readme file but it always return nothing (blank) (without the BaseNotAuthenticatedApiTest class)

Undefined method AuthApi::apiSig() in AuthApi->getToken()

Trying to authenticate a user on Last.fm with the following code:

    $auth = new AuthApi('gettoken', [
      'apiKey' => $api_key,
      'secret' => $api_secret,
    ]);

    $auth = new AuthApi('getsession', [
      'apiKey' => $api_key,
      'secret' => $api_secret,
      'token' => $auth->token,
    ]);

Getting:

Error: Call to undefined method LastFmApi\Api\AuthApi::apiSig() in LastFmApi\Api\AuthApi->getToken() (line 140 of vendor\matto1990\lastfm-api\src\lastfmapi\Api\AuthApi.php).

Seems that AuthApi class should extend the BaseApi, but it does not.

Can not get playlist.fetch working

I want to get information from a playlist of a user using the playlist.php and the fetch function

Want I want to achieve is, that I can play the playlist in a javascript player like Soundmanager2 as playlist.

composer install not passing without api key in .env

Hi Matt,
when I use deployer while using your repository "composer install" command fails with:
[LastFmApi\Exception\InvalidArgumentException]
Must send an apiKey, secret, usernamne, subcriber and sessionKey in the call for setsession

Temporary solution is setting LASTFM_API_KEY variable in .env file.
My guess is that it commes from one of tests. Do tests require any value set in .env file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.