forked from mlw157/eos-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequests.cs
64 lines (47 loc) · 2.27 KB
/
Requests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
using Newtonsoft.Json;
namespace eos_bot
{
class Requests
{
public static async Task<string> GetSteamName(string steamId)
{
var httpClient = new HttpClient();
string getUrl = $"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?steamids={steamId}&key=6833211F087334F5B31C57BC41A4A8E2";
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(getUrl);
var content = httpResponseMessage.Content;
var data = await content.ReadAsStringAsync();
dynamic parsedData = JsonConvert.DeserializeObject(data);
string playerName = parsedData.response.players[0].personaname;
return playerName;
}
public static async Task<string> GetSteamPicture(string steamId)
{
var httpClient = new HttpClient();
string getUrl = $"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?steamids={steamId}&key=6833211F087334F5B31C57BC41A4A8E2";
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(getUrl);
var content = httpResponseMessage.Content;
var data = await content.ReadAsStringAsync();
dynamic parsedData = JsonConvert.DeserializeObject(data);
string playerAvatar = parsedData.response.players[0].avatarfull;
return playerAvatar;
}
public static async Task<string> GetSteamProfileLink(string steamId)
{
var httpClient = new HttpClient();
string getUrl = $"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?steamids={steamId}&key=6833211F087334F5B31C57BC41A4A8E2";
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(getUrl);
var content = httpResponseMessage.Content;
var data = await content.ReadAsStringAsync();
dynamic parsedData = JsonConvert.DeserializeObject(data);
string profileLink = parsedData.response.players[0].profileurl;
return profileLink;
}
}
}