Steam can act as an OpenID provider. This allows your application to authenticate a user's SteamID without requiring them to enter their Steam username or password on your site (which would be a violation of the API Terms of Use.) Just download an OpenID library for your language and platform of choice and use http://steamcommunity.com/openid as the provider. The returned Claimed ID will contain the user's 64-bit SteamID. The Claimed ID format is: http://steamcommunity.com/openid/id/<steamid>
<?php
/**
*
* @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 & 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) ? '&' : '&';
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 : '';
}
}
How to add openid to XenForo?This would require OpenID. I have found a script that does it, but I haven't looked trough it yet, so not sure if it would work on XF. Zend haves something on OpenID though.
PHP:<?php /** * * @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 & 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) ? '&' : '&'; 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 : ''; } }
yep .. bunch of us have been asking for this for a while
... and you may interested that the administrator for steam community forums has been known to post here![]()
I found how to use itThis would require OpenID. I have found a script that does it, but I haven't looked trough it yet, so not sure if it would work on XF. Zend haves something on OpenID though.
PHP:<?php /** * * @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 & 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) ? '&' : '&'; 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 : ''; } }
$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>";
}
I'll see what I can do when I get my XenForo back...I found how to use it
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>"; }
Now i need to find how to add this in XenForo, so it will work like FaceBook integration![]()
yep .. bunch of us have been asking for this for a while
... and you may interested that the administrator for steam community forums has been known to post here![]()
Simple way:oh btw,
I have steamid as a user field, and I have steam badge in my "post bit", but have never figured out openid (plus I disabled the twitter auth coz no one was using it)
We use essential cookies to make this site work, and optional cookies to enhance your experience.