Created
April 12, 2018 04:35
-
-
Save tehp/6ed1101ec963a52f8ca925e088d67dab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetIP() | |
{ | |
WebRequest request = WebRequest.Create(_url + "/api/gameserver"); | |
request.Credentials = CredentialCache.DefaultCredentials; | |
((HttpWebRequest)request).UserAgent = UserAgent; | |
request.Method = "GET"; | |
request.ContentType = "application/x-www-form-urlencoded"; | |
WebResponse response = request.GetResponse(); | |
Stream dataStream = response.GetResponseStream(); | |
StreamReader reader = new StreamReader(dataStream); | |
string responseFromServer = reader.ReadToEnd(); | |
dynamic res = JsonConvert.DeserializeObject(responseFromServer); | |
Console.Write(responseFromServer); | |
reader.Close(); | |
dataStream.Close(); | |
response.Close(); | |
if (res != null) | |
{ | |
return res.ip; | |
} | |
return "err"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment