Get tolken, blank output

 
    • ilija666 sa...
    • Användare
    • 10 apr 2012, 16:43

    Get tolken, blank output

    Using the code below i succesfully get tolken, but when i get redirected to my site http://www.duhovnost.in.rs/muzickepreporuke/ath.php?tolken=blabla i get blank output. Im reallt frustrated with this because even php debugger i use show no errors. All help will be appreciated.


    <?php

    require 'lastfmapi/lastfmapi.php';


    if ( !empty($_GET['token']) ) {
    $vars = array(
    'apiKey' => 'key ',
    'secret' => 'secret ',
    'token' => $_GET['token']
    );

    $auth = new lastfmApiAuth('getsession', $vars);
    if ($auth==false)
    echo "greska u metodi";
    $file = fopen('auth.txt', 'w');
    if ($file==false)
    echo "greska u otvaranju fajla";
    $contents = $auth->apiKey."\n".$auth->secret."\n".$auth->username."\n".$auth->sessionKey."\n".$auth->subscriber;
    fwrite($file, $contents, strlen($contents));
    fclose($file);

    echo 'New key has been generated and saved to auth.txt<br /><br />';
    echo '<a href="'.$_SERVER['PHP_SELF'].'">Reload</a>';
    }
    else {
    $file = fopen('auth.txt', 'r');
    $vars = array(
    'apiKey' => trim(fgets($file)),
    'secret' => trim(fgets($file)),
    'username' => trim(fgets($file)),
    'sessionKey' => trim(fgets($file)),
    'subscriber' => trim(fgets($file))
    );
    $auth = new lastfmApiAuth('setsession', $vars);
    if($auth==false){
    echo "greska sa autentifikacijskom metodom";}
    echo '<b>API Key:</b> '.$auth->apiKey.'<br />';
    echo '<b>Secret:</b> '.$auth->secret.'<br />';
    echo '<b>Username:</b> '.$auth->username.'<br />';
    echo '<b>Session Key:</b> '.$auth->sessionKey.'<br />';
    echo '<b>Subscriber:</b> '.$auth->subscriber.'<br /><br />';

    echo '<a href="http://www.last.fm/api/auth/?api_key=51f4a9fdf2e8b016365ddae43ad2912d&cb=http://www.duhovnost.in.rs/muzickepreporuke/ath.php">Get New Key</a>';
    }

    ?>

    • ilija666 sa...
    • Användare
    • 10 apr 2012, 21:35
    some answer please?

    • tburny sa...
    • Forum Moderator
    • 12 apr 2012, 14:05
    $auth = new lastfmApiAuth('setsession', $vars);
    if($auth==false){
    echo "greska sa autentifikacijskom metodom";}
    echo '<b>API Key:</b> '.$auth->apiKey.'<br />';
    echo '<b>Secret:</b> '.$auth->secret.'<br />';
    echo '<b>Username:</b> '.$auth->username.'<br />';
    echo '<b>Session Key:</b> '.$auth->sessionKey.'<br />';
    echo '<b>Subscriber:</b> '.$auth->subscriber.'<br /><br />';

    echo '<a href="http://www.last.fm/api/auth/?api_key=51f4a9fdf2e8b016365ddae43ad2912d&cb=http://www.duhovnost.in.rs/muzickepreporuke/ath.php">Get New Key</a>';
    }

    $auth should be of type lastfmApiAuth. Thus it is an object which cannot equal false, so the if block is ignored. At least if PHP isn't acting weird - like in this bug

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
Anonyma användare kan inte skriva inlägg. Vänligen logga in eller skapa ett konto för att göra inlägg i forumen.