public function tearDown() { SteamId::clearCache(); }
/** * Creates a new instance of a Golden Wrench with the given data * * @param stdClass $wrenchData The JSON data for this wrench * @throws SteamCondenserException If the SteamId for the owner of the * wrench cannot be created */ private function __construct($wrenchData) { $this->date = (int) $wrenchData->timestamp; $this->id = (int) $wrenchData->itemID; $this->number = (int) $wrenchData->wrenchNumber; $this->owner = SteamId::create((string) $wrenchData->steamID, false); }
/** * Creates new entry instance for the given XML data and leaderboard * * @param SimpleXMLElement $entryData The XML data of the leaderboard of * the leaderboard entry * @param GameLeaderboard $leaderboard The leaderboard this entry belongs * to */ public function __construct(SimpleXMLElement $entryData, GameLeaderboard $leaderboard) { $this->steamId = SteamId::create((string) $entryData->steamid, false); $this->score = (int) $entryData->score; $this->rank = (int) $entryData->rank; $this->leaderboard = $leaderboard; }
function steamid2dotaid($playname) { try { $id = SteamId::create($playname); } catch (SteamCondenserException $s) { echo "steam name does not exist!"; } $id_dota = $id->getSteamId64(); return $id_dota; }
/** * Fetches the friends of this user * * This creates a new <var>SteamId</var> instance for each of the friends * without fetching their data. * * @see getFriends() * @see __construct() * @throws SteamCondenserException if an error occurs while parsing the * data */ private function fetchFriends() { $friendsData = $this->getData($this->getBaseUrl() . '/friends?xml=1'); $this->friends = array(); foreach ($friendsData->friends->friend as $friend) { $this->friends[] = SteamId::create((string) $friend, false); } }
/** * Fetches the friends of this user */ private function fetchFriends() { $url = $this->getBaseUrl() . '/friends?xml=1'; $this->friends = array(); $friendsData = new SimpleXMLElement(file_get_contents($url)); foreach ($friendsData->friends->friend as $friend) { $this->friends[] = SteamId::create((string) $friend, false); } }
/** * Parses the data about this groups members */ public function fetchMembers() { $this->members = array(); $page = 0; do { $page++; $url = "{$this->getBaseUrl()}/memberslistxml?p={$page}"; $memberData = new SimpleXMLElement(file_get_contents($url)); if ($page == 1) { $this->groupId64 = (string) $memberData->groupID64; } $totalPages = (int) $memberData->totalPages; foreach ($memberData->members->steamID64 as $member) { array_push($this->members, SteamId::create($member, false)); } } while ($page <= $totalPages); $this->fetchTime = time(); }
/** * Creates a new inventory object for the given user. This calls * <var>fetch()</var> to update the data and create the GameItem instances * contained in this player's inventory * * @param int $appId The application ID of the game * @param string $steamId64 The 64bit Steam ID of the user * @param bool $fetchNow Whether the data should be fetched now * @throws WebApiException on Web API errors */ protected function __construct($appId, $steamId64, $fetchNow = true) { $this->appId = $appId; $this->steamId64 = $steamId64; $this->user = SteamId::create($steamId64, false); if ($fetchNow) { $this->fetch(); } $this->cache(); array_keys(self::$cache); array_keys(self::$cache[$appId]); }
/** * Refreshes a user, or all users, Steam data * @param type $id * @return json */ public function refresh($id = null) { // If a specific user has been refreshed if (!is_null($id)) { $data = Input::all(); try { $steamObject = new SteamId($data['community_id']); $update = ['nickname' => $steamObject->getNickname(), 'avatar' => $steamObject->getMediumAvatarUrl()]; $this->users->edit($data['id'], $update); } catch (Exception $e) { return $this->jsonResponse(400, false, $e->getMessage()); } return $this->jsonResponse(200, true, 'User details refreshed!', $this->users->getWithRoles($data['id'])); } else { $users = $this->users->getAll(); try { foreach ($users as $user) { $steamObject = new SteamId($user['community_id']); $update = ['nickname' => $steamObject->getNickname(), 'avatar' => $steamObject->getMediumAvatarUrl()]; $this->users->edit($user['id'], $update); } } catch (Exception $e) { return $this->jsonResponse(400, false, $e->getMessage()); } return $this->jsonResponse(200, true, 'The users have been updated!', $this->users->getWithRoles()); } }
/** * Returns the base Steam Community URL for the stats contained in this * object * * @return string The base URL used for queries on these stats */ public function getBaseUrl() { return self::_getBaseUrl($this->user->getId(), $this->game->getId()); }
$logtag = $row['logtag']; $message = htmlentities( $row['message'] ); $time = $row['time_modified']; $name = $row['name']; try { $profile = SteamId::convertSteamIdToCommunityId($steamid); } catch(Exception $e) { $profile = 'ERROR'; } preg_match_all($pattern, $message, $matches); $steamid2 = $matches[0][1]; $statsinfo[3] = "right"; if ($steamid != $steamid2 && $steamid2 != "") { $matchprofile = SteamId::convertSteamIdToCommunityId($steamid2); $statsinfo[2] = $steamid2; $matchurl = "<a href=http://steamcommunity.com/profiles/$matchprofile target=_blank>$steamid2></a>" . getstatsurl($statsinfo); } $message = str_replace($steamid2, $matchurl, $message); $statsinfo[2] = $steamid; echo "<tr class=\"elements\"> <td width=\"200\" nowrap=\"nowrap\">$servername</td> <td width=\"200\" nowrap=\"nowrap\"><a href=\"http://steamcommunity.com/profiles/$profile\" title=\"$name\" target=_blank>$name" . getstatsurl($statsinfo) . "</a></td> <td width=\"120\" nowrap=\"nowrap\">$logtag</td> <td width=\"100%\">$message</td> <td width=\"120\" nowrap=\"nowrap\">$time</td> </tr>\n"; } echo '</table><div style="clear:both;"></div></div>';
public function testGamesParser() { $steamId = new SteamId('koraktor', false); print_r($steamId->getGames()); }
/** * Clears the group cache */ public static function clearCache() { self::$steamIds = array(); }
$_STEAMAPI = "YOURSTEAMAPIKEY"; try { $openid = new LightOpenID('localhost:8080'); if (!$openid->mode) { if (isset($_GET['login'])) { $openid->identity = 'http://steamcommunity.com/openid/?l=english'; // This is forcing english because it has a weird habit of selecting a random language otherwise header('Location: ' . $openid->authUrl()); } ?> <form action="?login" method="post"> <input type="image" src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.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/76561197960435530 // 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, $steamUser); echo "User is logged in (steamID: {$steamUser['1']})\n"; $steamUser = new SteamId('00000000000000000'); echo "Welcome, " . $steamUser->getNickname(); } } } catch (ErrorException $e) { echo $e->getMessage(); }
/** * Fetches a specific page of the member listing of this group * * @param int $page The member page to fetch * @return int The total number of pages of this group's member listing * @see #fetchMembers() */ private function fetchPage($page) { $url = "{$this->getBaseUrl()}/memberslistxml?p={$page}"; $memberData = $this->getData($url); if ($page == 1) { preg_match('/\\/([0-9a-f]+)\\.jpg$/', (string) $memberData->groupDetails->avatarIcon, $matches); $this->avatarHash = $matches[1]; $this->customUrl = (string) $memberData->groupDetails->groupURL; $this->groupId64 = (string) $memberData->groupID64; $this->name = (string) $memberData->groupDetails->groupName; $this->headline = (string) $memberData->groupDetails->headline; $this->summary = (string) $memberData->groupDetails->summary; } $this->memberCount = (int) $memberData->memberCount; $totalPages = (int) $memberData->totalPages; foreach ($memberData->members->steamID64 as $member) { array_push($this->members, SteamId::create($member, false)); } return $totalPages; }
public function testConvertSteamIdToCommunityId() { $steamId64 = SteamId::convertSteamIdToCommunityId('STEAM_0:0:12345'); $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $steamId64); $this->assertEquals('76561197960290418', $steamId64); }
echo "<table>"; echo "<tr bgcolor=FF8C00><th width=14%>Name</th><th width=25%>Score</th><th width=14%>Ping</th><th width=14%>steamid</th><th width=14%>connect time</th><th width=14%>state</th><th width=14%>ip</th><th width=14% nowrap=nowrap>Quick Info</th></tr>"; $i=0; foreach($players as $player) { $steamid = $player->getsteamid(); $statsinfo[2] = $steamid; $name = $player->getName(); if ($i%2 == 0) { echo "<tr class=d0>"; $i++; } else { echo "<tr class=d1>"; $i++; } if ($name == "") { echo "<td>New player connecting</td>"; } else { echo "<td>{$player->getName()}</td>"; } echo "<td>{$player->getScore()}</td>"; echo "<td>{$player->getPing()}</td>"; try { $profile = SteamId::convertSteamIdToCommunityId($steamid); } catch(Exception $e) { $profile = 'ERROR'; } // $steamid = $player->getsteamid(); echo "<td><a href=\"http://steamcommunity.com/profiles/$profile\" title=\"$name\" target=_blank>$steamid</a></td>"; $seconds=$player->getconnectTime(); $time=sec2hms($seconds); echo "<td>$time</td>"; echo "<td>{$player->getstate()}</td>"; echo "<td>{$player->getipaddress()}</td>"; $statsinfo[3] = "none"; $steamrep[0] = "steamrep"; $steamrep[1] = "http://www.steamrep.com/profiles";