public function validate($timeout = 30)
    {
        $response = null;

        try {
            $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',
            );

            $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; 
            }

            $params['openid.mode'] = 'check_authentication';

            $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,
                    'timeout' => $timeout
                    ),
            ));

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

            preg_match("#^https://steamcommunity.com/openid/id/([0-9]{17,25})#", $_GET['openid_claimed_id'], $matches);

            $steamID64 = is_numeric($matches[1]) ? $matches[1] : 0;

            $response = preg_match("#is_valid\s*:\s*true#i", $result) == 1 ? $steamID64 : null;

        } catch (Exception $e) {
            $response = null;
        }

        if (is_null($response)) {
            throw new Exception('The Steam login request timed out or was invalid');
        }

        return $response;
    }
public function validate($timeout = 30)
    {
        $response = null;

        try {
            $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',
            );

            $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; 
            }

            $params['openid.mode'] = 'check_authentication';

            $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,
                    'timeout' => $timeout
                    ),
            ));

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

            preg_match("#^https://steamcommunity.com/openid/id/([0-9]{17,25})#", $_GET['openid_claimed_id'], $matches);

            $steamID64 = is_numeric($matches[1]) ? $matches[1] : 0;

            $response = preg_match("#is_valid\s*:\s*true#i", $result) == 1 ? $steamID64 : null;

        } catch (Exception $e) {
            $response = null;
        }

        if (is_null($response)) {
            throw new Exception('The Steam login request timed out or was invalid');
        }

        return $response;
    }
public function validate ( $ timeout = 30 ) { $ response = null ; try { $ 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' , ) ; $ 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 ; } $ params [ 'openid.mode' ] = 'check_authentication' ; $ 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 , 'timeout' => $ timeout ) , ) ) ; $ result = file_get_contents ( self :: $ openId , false , $ context ) ; preg_match ( "#^https://steamcommunity.com/openid/id/([0-9]{17,25})#" , $ _GET [ 'openid_claimed_id' ] , $ matches ) ; $ steamID64 = is_numeric ( $ matches [ 1 ] ) ? $ matches [ 1 ] : 0 ; $ response = preg_match ( "#is_valid\s*:\s*true#i" , $ result ) == 1 ? $ steamID64 : null ; } catch ( Exception $ e ) { $ response = null ; } if ( is_null ( $ response ) ) { throw new Exception ( 'The Steam login request timed out or was invalid' ) ; } return $ response ; }
Validates a Steam login request and returns the users Steam Community ID

@return string
Validates a Steam login request and returns the users Steam Community ID