1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

SteamCommunity integration (like FaceBook)

Discussion in 'Add-on Requests [Archive]' started by kira.ee, May 2, 2011.

  1. kira.ee

    kira.ee Member

    Good day!

    Can someone make a feature, which will allow to login via SteamCommunity.com in forum, like the FaceBook feature does. And to merge usual accounts with SteamCommunity.

    Thank you in advance, who can do it!
  2. Jesepi

    Jesepi Well-Known Member

    I would like this as my community is PC gaming focused, and almost everyone has a steam account.

    http://steamcommunity.com/dev :
  3. José Guedes

    José Guedes Active Member

    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.

    * @package Steam Community API
    * @copyright (c) 2010 ichimonai.com
    * @license http://opensource.org/licenses/mit-license.php The MIT License

    class SteamSignIn
    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;' '&';
    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']);
    $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_LOGINfalse$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) == $steamID64 '';
    krstep and kira.ee like this.
  4. Reeve of Shinra

    Reeve of Shinra Well-Known Member

    This would be pretty good to have (I also have a gaming community oriented site).
  5. kira.ee

    kira.ee Member

    How to add openid to XenForo? :D
  6. dieketzer

    dieketzer Well-Known Member

  7. TerminalAddict

    TerminalAddict Active Member

    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 :)
  8. TerminalAddict

    TerminalAddict Active Member

    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)
  9. José Guedes

    José Guedes Active Member

    I wonder who's that person...
  10. TerminalAddict

    TerminalAddict Active Member

  11. kira.ee

    kira.ee Member

    I really don`t care who is admin and who is not, i just want Steam integration in my forum :)
  12. kira.ee

    kira.ee Member

    I found how to use it :)

    $steam_login_verify SteamSignIn::validate();
    "success + $steam_login_verify";
    $steam_sign_in_url SteamSignIn::genUrl();
    "<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 :)
  13. José Guedes

    José Guedes Active Member

    I'll see what I can do when I get my XenForo back...
  14. tonjohn

    tonjohn Member

    Lies! :p

    Simple way:

    Step 1: Find an OpenID library you like
    Step 2: Create a Xenforo page where a user clicks the "login with Steam" button and perform the actual OAuth authentication
    Step 3: Take the returned data, extract the 64bit SteamID, and write that to a new column in the User table

    That is the easy part. You will then need to update the login and account creation system to handle Steam OAuth logins. And if you want to get really fancy, you write a class that leverages the Steam web apis and replace forum avatars with Steam community avatars, forum usernames with Steam personas, show ingame status, etc.

    All work I'm planning to do but not until we upgrade our forums to vb4.

    But if Mike and Kier wanted to do the hard work for me, thats just one more reason for us to switch :)
  15. Binari0

    Binari0 Member

Share This Page