示例#1
0
        private static EResult ResolveVanityURL(string input, EVanityURLType urlType, out SteamID steamID)
        {
            steamID = new SteamID();

            using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", Settings.Current.Steam.WebAPIKey))
            {
                steamUser.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;

                KeyValue response;

                try
                {
                    response = steamUser.ResolveVanityURL(vanityurl: input, url_type: (int)urlType);
                }
                catch (WebException)
                {
                    return(EResult.Timeout);
                }

                var eResult = (EResult)response["success"].AsInteger();

                if (eResult == EResult.OK)
                {
                    steamID.SetFromUInt64((ulong)response["steamid"].AsLong());
                }

                return(eResult);
            }
        }
示例#2
0
        private static async Task <(EResult result, SteamID steamID)> ResolveVanityURL(string input, EVanityURLType urlType)
        {
            var     steamID = new SteamID();
            EResult eResult;

            using (var steamUser = Steam.Configuration.GetAsyncWebAPIInterface("ISteamUser"))
            {
                steamUser.Timeout = TimeSpan.FromSeconds(5);

                KeyValue response;

                try
                {
                    response = await steamUser.CallAsync(HttpMethod.Get, "ResolveVanityURL", 1,
                                                         new Dictionary <string, object>
                    {
                        { "vanityurl", input },
                        { "url_type", (int)urlType }
                    });
                }
                catch (HttpRequestException)
                {
                    return(EResult.Timeout, steamID);
                }

                eResult = (EResult)response["success"].AsInteger();

                if (eResult == EResult.OK)
                {
                    steamID.SetFromUInt64((ulong)response["steamid"].AsLong());
                }
            }

            return(eResult, steamID);
        }
        private static EResult ResolveVanityURL(string input, EVanityURLType urlType, out SteamID steamID)
        {
            steamID = new SteamID();

            using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", Settings.Current.Steam.WebAPIKey))
            {
                steamUser.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;

                KeyValue response;

                try
                {
                    response = steamUser.ResolveVanityURL( vanityurl: input, url_type: (int)urlType );
                }
                catch (WebException)
                {
                    return EResult.Timeout;
                }

                var eResult = (EResult)response["success"].AsInteger();

                if (eResult == EResult.OK)
                {
                    steamID.SetFromUInt64((ulong)response["steamid"].AsLong());
                }

                return eResult;
            }
        }