Beispiel #1
0
        public static async Task APIRequest()
        {
            var apiKey     = "API KEY";
            var json       = "SESSION JSON CONTENT";
            var webSession = JsonConvert.DeserializeObject <WebSession>(json);

            if (webSession?.HasEnoughInfo() == true)
            {
                var webAccess = new SteamWebAccess(webSession);
                var webAPI    = new SteamWebAPI(apiKey, webAccess);

                var tf2News = await webAPI.RequestDynamic(
                    "ISteamNews",
                    SteamWebAccessRequestMethod.Get,
                    "GetNewsForApp",
                    "v2",
                    new
                {
                    appid = 440
                }
                    );

                // Show tf2News
            }
        }
Beispiel #2
0
        public static async Task GetAPIKey()
        {
            var json       = "SESSION JSON CONTENT";
            var webSession = JsonConvert.DeserializeObject <WebSession>(json);

            if (webSession?.HasEnoughInfo() == true)
            {
                var webAccess = new SteamWebAccess(webSession);

                var apiKey = await SteamWebAPI.GetApiKey(webAccess);

                if (string.IsNullOrWhiteSpace(apiKey))
                {
                    if (await SteamWebAPI.RegisterApiKey(webAccess, "www.example.com"))
                    {
                        apiKey = await SteamWebAPI.GetApiKey(webAccess);
                    }
                    else
                    {
                        // Failed to register a new API key for this account
                    }
                }

                if (!string.IsNullOrWhiteSpace(apiKey))
                {
                    // Retrieved a valid API key associated with the account represented by the passed WebSession
                    // Use this API key to create an instance of SteamWebAPI or just save it somewhere for later use

                    var webAPI = new SteamWebAPI(apiKey, webAccess);
                }
            }
        }