Carlos Barros Posted April 6, 2013 at 05:49 PM Report #501980 Posted April 6, 2013 at 05:49 PM (edited) Boa tarde, Eu gostaria de saber como fazer um WebRequest em C. por exemplo em C#: ASCIIEncoding enconding = new ASCIIEncoding(); String postData = "ip=" + ip + "&name=" + name; byte[] data = enconding.GetBytes(postData); WebRequest request = WebRequest.Create("http://localhost/insert.php"); 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(); stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); MessageBox.Show(sr.ReadToEnd()); sr.Close(); stream.Close(); PS: Eu gostaria de saber como fazer em C e NÃO C#. Obrigado Edited April 6, 2013 at 05:49 PM by Carlos Barros
pmg Posted April 6, 2013 at 06:33 PM Report #501985 Posted April 6, 2013 at 06:33 PM Tens que usar uma biblioteca, por exemplo: libcurl. Se preferes fazer tudo "à pata" (com sockets), aconselho-te uma leitura do "Beej's Guide to Network Programming". What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código!
Carlos Barros Posted April 6, 2013 at 06:46 PM Author Report #501989 Posted April 6, 2013 at 06:46 PM Obrigado, vou ver se consigo utilizar a biblioteca libcurl 😉
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now