CSharpTradeOffers.Community.SteamUserHandler.ResolveVanityUrl C# (CSharp) Method

ResolveVanityUrl() public method

Resolves a vanity url into a SteamId64.
public ResolveVanityUrl ( string vanityUrl, int urlType = 1 ) : ResolveVanityUrlResult
vanityUrl string The vanity url part of the url (not whole url). ex: fatherfoxxy NOT https://steamcommunity.com/id/FatherFoxxy
urlType int /// 1 - (default) Individual profile /// 2 - Group Profile /// 3 - Offical Game Group Profile ///
return ResolveVanityUrlResult
        public ResolveVanityUrlResult ResolveVanityUrl(string vanityUrl, int urlType = 1)
        {
            const string url = BaseUrl + "ResolveVanityURL/v1/";
            var data = new Dictionary<string, string>
            {
                {"key", _apiKey},
                {"vanityurl", vanityUrl},
                {"url_type", urlType.ToString()}
            };
            return _web.Fetch(url, "GET", data, null, false).DeserializeJson<ResolveVanityUrlBaseResult>().Response;
        }

Usage Example

 private SteamId ParseId()
 {
     try
     {
         SteamId id = null;
         if (IdBox.Text.StartsWith("STEAM_"))
         {
             id = new SteamId(IdBox.Text);
         }
         else
         {
             ulong tryParseUlong;
             if (ulong.TryParse(IdBox.Text, out tryParseUlong))
             {
                 id = new SteamId(tryParseUlong);
             }
             else
             {
                 string apiKey = GetInput(
                     "If you are trying to resolve a CustomURL, please enter in your API key. Please note this is not necessary for SteamID/SteamID64.",
                     "API key required!");
                 _userHandler = new SteamUserHandler(apiKey);
                 if (ulong.TryParse(_userHandler.ResolveVanityUrl(IdBox.Text).SteamId, out tryParseUlong))
                 {
                     id = new SteamId(tryParseUlong);
                 }
             }
         }
         return id;
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid SteamId, please try using a valid SteamID, SteamID64, or CustomURL.");
         return null;
     }
 }