Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using RestSharp;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Newtonsoft.Json;
- namespace Lookup
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Equals("") == false)
- {
- textBox2.Text = FetchCurrentIpLocation(textBox1.Text);
- }
- }
- private string FetchCurrentIpLocation(string strIP)
- {
- string strIpLocation = string.Empty;
- var client = new RestClient("https://ipapi.co/"+strIP+"json/");
- var request = new RestRequest()
- {
- Method = Method.GET
- };
- var response = client.Execute(request);
- var dictionary = JsonConvert.DeserializeObject<IDictionary>(response.Content);
- foreach (var key in dictionary.Keys)
- {
- strIpLocation += key.ToString() + ": " + dictionary[key] + "\r\n";
- }
- return strIpLocation;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement