문제

This is an Steam Authentication Methord but its giving me some Notices so can someone help me to resolve this

    <?php 

$steam_login_verify = SteamSignIn::validate();
if(!empty($steam_login_verify))
{
echo "success + $steam_login_verify";
}
else
{
$steam_sign_in_url = SteamSignIn::genUrl();
echo '<a href=\"$steam_sign_in_url\"><img src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_noborder.png"/></a>';
}
/**
*
* @package Steam Community API
* @copyright (c) 2010 ichimonai.com
* @license http://opensource.org/licenses/mit-license.php The MIT License
*
*/

class SteamSignIn
{
    const STEAM_LOGIN = 'https://steamcommunity.com/openid/login';

    /**
    * Get the URL to sign into steam
    *
    * @param mixed returnTo URI to tell steam where to return, MUST BE THE FULL URI WITH THE PROTOCOL
    * @param bool useAmp Use &amp; in the URL, true; or just &, false. 
    * @return string The string to go in the URL
    */
    public static function genUrl($returnTo = false, $useAmp = true)
    {
        $returnTo = (!$returnTo) ? (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] : $returnTo;

        $params = array(
            'openid.ns'         => 'http://specs.openid.net/auth/2.0',
            'openid.mode'       => 'checkid_setup',
            'openid.return_to'  => $returnTo,
            'openid.realm'      => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'],
            'openid.identity'   => 'http://specs.openid.net/auth/2.0/identifier_select',
            'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
        );

        $sep = ($useAmp) ? '&amp;' : '&';
        return self::STEAM_LOGIN . '?' . http_build_query($params, '', $sep);
    }

    /**
    * Validate the incoming data
    *
    * @return string Returns the SteamID64 if successful or empty string on failure
    */
    public static function validate()
    {
        // Star off with some basic params
        $params = array(
            'openid.assoc_handle'   => $_GET['openid_assoc_handle'],
            'openid.signed'         => $_GET['openid_signed'],
            'openid.sig'            => $_GET['openid_sig'],
            'openid.ns'             => 'http://specs.openid.net/auth/2.0',
        );

        // Get all the params that were sent back and resend them for validation
        $signed = explode(',', $_GET['openid_signed']);
        foreach($signed as $item)
        {
            $val = $_GET['openid_' . str_replace('.', '_', $item)];
            $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($val) : $val; 
        }

        // Finally, add the all important mode. 
        $params['openid.mode'] = 'check_authentication';

        // Stored to send a Content-Length header
        $data =  http_build_query($params);
        $context = stream_context_create(array(
            'http' => array(
                'method'  => 'POST',
                'header'  => 
                    "Accept-language: en\r\n".
                    "Content-type: application/x-www-form-urlencoded\r\n" .
                    "Content-Length: " . strlen($data) . "\r\n",
                'content' => $data,
            ),
        ));

        $result = file_get_contents(self::STEAM_LOGIN, false, $context);

        // Validate wheather it's true and if we have a good ID
        preg_match("#^http://steamcommunity.com/openid/id/([0-9]{17,25})#", $_GET['openid_claimed_id'], $matches);
        $steamID64 = is_numeric($matches[1]) ? $matches[1] : 0;

        // Return our final value
        return preg_match("#is_valid\s*:\s*true#i", $result) == 1 ? $steamID64 : '';
    }
}        

?>

This is a simple sign in through steam methord which i found out from here http://forums.steampowered.com/forums/showthread.php?t=1430511 What are the errors? There are the errors

Notice: Undefined index: openid_assoc_handle in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 130

Notice: Undefined index: openid_signed in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 131

Notice: Undefined index: openid_sig in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 132

Notice: Undefined index: openid_signed in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 137

Notice: Undefined index: openid_ in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 140

Notice: Undefined index: openid_claimed_id in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 163

Notice: Undefined offset: 1 in C:\Users\karan\Desktop\xampp\htdocs\LOL\index.php on line 164

Well i am not aware why are these errors coming http://i.imgur.com/pedSj7k.png Thanks in advance _Frost

도움이 되었습니까?

해결책

Based on the comments in the thread you linked, it looks like that method may no longer work. I provided an alternate way of using the Steam API Authentication in this answer that may be helpful to you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top