Пример #1
0
        // Parses player summaries.
        private static PlayerSummary Parse(XElement xml)
        {
            if (xml == null)
            {
                return(null);
            }

            ElementParser parser = new ElementParser(xml);
            PlayerSummary result = new PlayerSummary
            {
                Id             = parser.GetAttributeLong("steamid"),
                DisplayName    = parser.GetAttributeString("personaname"),
                Url            = parser.GetAttributeString("profileurl"),
                AvatarSmall    = parser.GetAttributeString("avatar"),
                AvatarMedium   = parser.GetAttributeString("avatarmedium"),
                AvatarLarge    = parser.GetAttributeString("avatarfull"),
                Status         = parser.GetAttributeInteger("personastate"),
                Visibility     = parser.GetAttributeInteger("communityvisibilitystate"),
                Configured     = parser.GetAttributeBoolean("profilestate"),
                LastSeen       = parser.GetAttributeDate("lastlogoff"),
                AllowsComments = parser.GetAttributeBoolean("commentpermission"),
                Name           = parser.GetAttributeString("realname"),
                PrimaryClan    = parser.GetAttributeLong("primaryclanid"),
                CreationDate   = parser.GetAttributeDate("timecreated"),
                AppId          = parser.GetAttributeInteger("gameid"),
                AppInfo        = parser.GetAttributeString("gameextrainfo"),
                ServerIp       = parser.GetAttributeIpAdress("gameserverip"),
                ServerPort     = parser.GetAttributePort("gameserverip"),
                CityId         = parser.GetAttributeInteger("loccityid"),
                Country        = parser.GetAttributeString("loccountrycode"),
                State          = parser.GetAttributeString("locstatecode")
            };

            return(result);
        }
Пример #2
0
        // Queries player summaries.
        public static PlayerSummary Query(string apikey, long playerId)
        {
            string    url = String.Format("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={0}&steamids={1}&format=xml", apikey, playerId);
            XDocument xml = GetXML(url);

            if (xml == null)
            {
                return(null);
            }

            XElement[] players = xml.Descendants("player").ToArray();
            if (players.Length <= 0)
            {
                return(null);
            }

            PlayerSummary result = Parse(xml.Descendants("player").ToArray()[0]);

            result.SharedGameOwner = GetSharedGameOwner(apikey, playerId, result.AppId);
            return(result);
        }