/**
  * 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;
 }
Пример #3
0
 public function testCaseInsensitivity()
 {
     SteamId::clearCache();
     $steamId = SteamId::create('koraktor', false);
     $steamId2 = SteamId::create('Koraktor', false);
     $steamId3 = SteamId::create('KORAKTOR', false, true);
     $this->assertTrue(SteamId::isCached('koraktor'));
     $this->assertEquals($steamId, $steamId2);
     $this->assertEquals($steamId, $steamId3);
 }
Пример #4
0
function steamid2dotaid($playname)
{
    try {
        $id = SteamId::create($playname);
    } catch (SteamCondenserException $s) {
        echo "steam name does not exist!";
    }
    $id_dota = $id->getSteamId64();
    return $id_dota;
}
Пример #5
0
 /**
  * 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();
 }
Пример #8
0
 /**
  * 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;
 }
 /**
  * Creates a <var>GameStats</var> object and fetches data from the Steam
  * Community for the given user and game
  *
  * @param string $steamId The custom URL or the 64bit Steam ID of the user
  * @param string $gameId The app ID or friendly name of the game
  * @throws SteamCondenserException if the stats cannot be fetched
  */
 protected function __construct($steamId, $gameId)
 {
     $this->user = SteamId::create($steamId, false);
     $url = self::_getBaseUrl($steamId, $gameId) . '?xml=all';
     $this->xmlData = $this->getData($url);
     if ($this->xmlData->error != null && !empty($this->xmlData->error)) {
         throw new SteamCondenserException((string) $this->xmlData->error);
     }
     $this->privacyState = (string) $this->xmlData->privacyState;
     if ($this->isPublic()) {
         preg_match('#http://steamcommunity.com/+app/+([1-9][0-9]*)#', (string) $this->xmlData->game->gameLink, $appId);
         $this->game = SteamGame::create((int) $appId[1], $this->xmlData->game);
         $this->hoursPlayed = (string) $this->xmlData->stats->hoursPlayed;
     }
 }
 /**
  * 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]);
 }