Jump to content
Sign in to follow this  
cskopytko

Pobieranie danych po połączeniu się przez SteamAuth z bazą danych Steam

Recommended Posts

Witam, po zalogowaniu do strony przez SteamAuth, nie dodaje danych tj. nick steamid64 link do av itp..

Spoiler

<?php
case 'login':
include 'openid.php';
try
{
  $openid = new LightOpenID('http://'.$_SERVER['SERVER_NAME'].'/');
  if (!$openid->mode) {
    $openid->identity = 'http://steamcommunity.com/openid/?l=russian';
    header('Location: ' . str_replace("ruletka", "ruletka", $openid->authUrl()));
  } elseif ($openid->mode == 'cancel') {
    echo '';
  } else {
    if ($openid->validate()) {
      $id = $openid->identity;
      $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
      preg_match($ptn, $id, $matches);
      $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=64EED54DCD71C31FF0C3FAAD77C3DDF3&steamids=$matches[1]";
      $json_object = file_get_contents($url);
      $json_decoded = json_decode($json_object);
      foreach ($json_decoded->response->players as $player) {
        $steamid = $player->steamid;
        $name = $player->personaname;
        $avatar = $player->avatar;
      }
      $hash = md5($steamid . time() . rand(1, 50));
      $sql = $db->query("SELECT * FROM `users` WHERE `steamid` = '" . $steamid . "'");
      $row = $sql->fetchAll(PDO::FETCH_ASSOC);
      if (count($row) == 0) {
        $db->exec("INSERT INTO `users` (`hash`, `steamid`, `name`, `avatar`) VALUES ('" . $hash . "', '" . $steamid . "', " . $db->quote($name) . ", '" . $avatar . "')");
      } else {
        $db->exec("UPDATE `users` SET `hash` = '" . $hash . "', `name` = " . $db->quote($name) . ", `avatar` = '" . $avatar . "' WHERE `steamid` = '" . $steamid . "'");
      }
      setcookie('hash', $hash, time() + 3600 * 24 * 7, '/');
      header('Location: http://www.link.pl/sets.php?id=' . $hash);
    }

 

 

Share this post


Link to post

Po pierwsze dumpuj odpowiedzi (var_dump) z serwera.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Create a New Account. It’s free and easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...