Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # Logging in with Steam accounts requires setting special identity, so this example shows how to do it.
- # http://steamcommunity.com/dev/
- require 'openid.php';
- try {
- # Change 'localhost' to your domain name.
- $openid = new LightOpenID('localhost');
- if(!$openid->mode) {
- if(isset($_GET['login'])) {
- $openid->identity = 'http://steamcommunity.com/openid';
- header('Location: ' . $openid->authUrl());
- }
- ?>
- <form action="?login" method="post">
- <input type="image" src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png">
- </form>
- <?php
- } elseif($openid->mode == 'cancel') {
- echo 'User has canceled authentication!';
- } else {
- if($openid->validate()) {
- $id = $openid->identity;
- // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
- // we only care about the unique account ID at the end of the URL.
- $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
- preg_match($ptn, $id, $matches);
- echo "User is logged in (steamID: $matches[1])\n";
- } else {
- echo "User is not logged in.\n";
- }
- }
- } catch(ErrorException $e) {
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement