PHP code example of danielburger1337 / steam-openid

1. Go to this page and download the library: Download danielburger1337/steam-openid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

danielburger1337 / steam-openid example snippets


 declare(strict_types=1);

use danielburger1337\SteamOpenId\SteamOpenID;

// RECOMMENDATION: register this in your psr-11 container.
$openId = new SteamOpenID(
    // REQUIRED: your OpenID "realm" (your host)
    'http://localhost:5000',
    // REQUIRED: your OpenID "return_to" URI (your callback URI)
    'http://localhost:5000/Callback.php',
    // OPTIONAL: your psr-18 implementation (defaults to symfony/http-client)
    new GuzzleHttp\Client(),
    // OPTIONAL: your psr-17 implementation (default to nyholm/psr7)
    new Nyholm\Psr7\Factory\Psr17Factory()
);

// start the authentication flow by redirecting the user to Steam.
header('Location: ' . $openId->constructCheckIdSetupUri());

// ... in Callback.php (or your callback controller method)

use danielburger1337\SteamOpenId\Exception\ExceptionInterface;

// When steam redirects the user back to your "return_to" URI,
// verify the provided parameters in the query string.

try {
    // This method returns the users 64-bit SteamID.
    $steamId = $openId->verifyCallback($_GET);
} catch (ExceptionInterface $e) {
    exit(var_dump('Failed to verify steam authentication :('));
}