I tried to use this code below(copied from somewhere) to POST my name to the website and start chatting but I receive 404 error; i guess i'm writing the wrong url or the string to be posted.
static void Main(string[] args)
{
string response = HttpPostRequest("https://tlk.io/tactic5", "name=Ali");
Console.WriteLine(response);
Console.ReadLine();
}
public static string HttpPostRequest(string url, string post)
{
var encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(post);
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
String result;
using (var sr = new StreamReader(response.GetResponseStream()))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
}
I guess the most important part of the html I should use is this:
<input id="participant_nickname" class="input-text join-input--
troll" name="participant[nickname]" placeholder="Name" size="30"
spellcheck="false" type="text">
I'm not a skilled programmer.