problem with fully authenticated method call.

 
  • problem with fully authenticated method call.

    Hi, loving the php library it's been a great help.

    Just one problem when trying to use full auth methods. Followed your usage directions all the way on the sourceforge site.
    I get as far as allowing $auth contain all the info. i.e. $auth->apiKey, $auth->secret, $auth->username etc. all contain what appears to be the correct data. (subscriber is 0 but i presume thats ok).

    I load this data into a db and when I retrieve it later and try to use it to set up full auth permission with the methods nothing seems to work.

    My code is as follows:
    ---------------------------------------------------------------------------
    //each of these variable contains the data from the db.
    $vars = array(
    'apiKey' => $ak,
    'secret' => $sec,
    'username' => $us,
    'sessionKey' => $ses,
    'subscriber' => $sub
    );
    $auth = new lastfmApiAuth('setsession', $vars);

    $apiClass = new lastfmApi();
    $userClass = $apiClass->getPackage($auth, 'user');

    $result = $userClass->getInfo();

    echo $result[name];
    ---------------------------------------------------------------------------

    Any help would be greatly apprecited, not sure where I'm going wrong.

    Thanks,
    Dan

    MixMasterM
  • It sounds like you're using the old version. Have a go at updating to the latest version 0.3.1 and see what happens.

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
  • So updated the version but to no joy.

    Switched round bit of code where method is called for user.getinfo and actually used some of your code just out of interest i.e. -
    -----------------------------------------------------------
    if ( $info = $userClass->getInfo() ) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($info);
    echo '</pre>';
    }
    else {
    die('<b>Error '.$userClass->error['code'].' - </b><i>'.$userClass->error['desc'].'</i>');
    }
    -----------------------------------------------------------
    So i get the error - Error 92 - Method requires full auth. Call auth.getSession using lastfmApiAuth class

    Could this mean one of my auth variables are incorrect for example session key? I will go off and have a good look at how I'm doing the earlier stages of getting the initial authentication. However any other suggestions would be great.

    Cheers

    MixMasterM
  • Maybe try echoing out the auth variables so you can see what they are. Do not post them on here though otherwise people can use your account and change stuff on it.

    Worth a try.

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
  • So echoed them out and it all seems in order

    apiKey - is my apikey
    secret - my secret key
    username - username of current user
    sessionKey - outputs a session key
    subscriber - 0

    Have changes code to the same as your examples so using your auth class I load the auth variables into the auth.txt no problem and can open and retrieve them fine.

    Tryed using library.addArtist example you put up which uses full auth but once more i get 'Error 92 - Method requires full auth. Call auth.getSession using lastfmApiAuth class'

    Really puzzled as to what is going wrong here. I presume this full auth is working for people though so if someone could post code they use that works that would be great.

    thanks

    MixMasterM
  • Can you change the subscriber value to be 1 for me to check it's not that.

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
  • Bingo that was the problem. Works now.

    Was thinking it might have been something to do with subscriber i.e. the isset($vars['subscriber']) change. But was using the latest version with that in it didn't seem to do anything. You know why?

    Anyway thanks for all the help, can get stuck into making apps now. :)

    MixMasterM
  • I'm not quite sure. I'll do a bit more testing and issue a bug fix if I find the solution.

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
    • ebotunes schrieb...
    • Abonnent
    • 3. Jun. 2009, 11:58
    Hi guys,

    I've just come across this problem as well. Using the latest version 0.7

    I hardcoded my subscriber flag to 1 and that seemed to fix it, so the line that needs fixed is line 247 of apibase.php, specifically the

    !empty($auth->subscriber)

    possibly to ...

    ($auth->subscriber=='0' || $auth->subscriber=='1')

    I've tested this and it works for an input value of 0 or 1

    Hope that helps!
    Iain

  • Thanks Iain!

    I've added that change to the SVN version and it will be release in the next version. If thats going to be a while I may just release it as a minor bug fix; just not at the minute as I have loads of exams now.

    Thanks again!

    Matt

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
    • ebotunes schrieb...
    • Abonnent
    • 3. Jun. 2009, 21:57
    Nice one Matt.

    Good luck with the exams!

    Iain

  • Thanks :)

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
  • I've issued a big fix for this. Download version 0.7.1 to get this issue fixed.

    ONGOING PROJECT! PHP Last.FM API (Download or SVN)
    Online Last.FM Player (Updated version is SVN only currently)
Anonyme Benutzer dürfen keine Beiträge schreiben. Bitte log dich ein oder registriere dich, um Beiträge in den Foren schreiben zu können.