public static XuidInfo GetUserId(string gamertag, string apikey) { logger.Debug("GamerTag sent to Api.GetUserId() is: " + gamertag); RestRequest req = new RestRequest("/v2/xuid/" + gamertag); req.AddHeader("X-AUTH", apikey); IRestResponse res = client.Execute(req); string JsonRes = res.Content; logger.Debug("Received response from API for Xuid: " + res.Content.ToString()); Xuid x = JsonConvert.DeserializeObject <Xuid>(JsonRes); XuidInfo xi = new XuidInfo(); xi.xuid = x.xuid; string error = x.error_message; if (error != "") { xi.success = false; xi.error = error; return(xi); } else { xi.success = true; return(xi); } }
private void button1_Click(object sender, EventArgs e) { if (gamertagBox.Text != "" || apikeyBox.Text == "" || pollrateBox.Value == 0 || Global.FilePath == "") { XuidInfo xuid = Api.GetUserId(gamertagBox.Text, apikeyBox.Text); if (xuid.success) { logger.Debug("After saving settings, Xuid is: " + xuid); Config.WriteConfigFile(gamertagBox.Text.Trim(), apikeyBox.Text.Trim(), (int)pollrateBox.Value, xuid.xuid, Global.FilePath); Config.ReadConfigFile(); WriteGamerScore(); InitTimer(); this.Hide(); myNotifyIcon.BalloonTipTitle = "Running in the background..."; myNotifyIcon.BalloonTipText = "Right-click the XBox icon in your system tray to exit or show the configuration window."; myNotifyIcon.ShowBalloonTip(5000); } else { MessageBox.Show(xuid.error); } } else { if (Global.FilePath == "") { MessageBox.Show("Please select a folder to save your gamerscore file to."); } else if (gamertagBox.Text != "" || apikeyBox.Text == "" || pollrateBox.Value == 0) { MessageBox.Show("Please fill out the form fully."); } } }