PHP code example of xpaw / steam-openid
1. Go to this page and download the library: Download xpaw/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/ */
xpaw / steam-openid example snippets
use xPaw\Steam\SteamOpenID;
$SteamOpenID = new SteamOpenID( $ReturnToUrl );
if( $SteamOpenID->ShouldValidate() )
{
try
{
$CommunityID = $SteamOpenID->Validate();
echo 'Logged in as ' . $SteamID;
}
catch( Exception $e )
{
echo 'Login failed';
}
}
else
{
header( 'Location: ' . $SteamOpenID->GetAuthUrl() );
}
$params = [
'openid_mode' => $_GET['openid_mode'] ?? null,
// etc...
];
$SteamOpenID = new SteamOpenID( $ReturnToUrl, $params );
class CustomSteamOpenID extends SteamOpenID
{
public function SendSteamRequest( array $Arguments ) : array
{
// Use your preferred HTTP client here
$httpClient = new YourHttpClient();
$response = $httpClient->post( self::SERVER, [
'form_params' => $Arguments,
'timeout' => 10,
'headers' => [
'User-Agent' => 'Your Custom User Agent'
]
] );
// array(http code as int, response as string)
return [ $response->getStatusCode(), $response->getBody() ];
}
}
$SteamOpenID = new CustomSteamOpenID( $ReturnToUrl );