I can fake a GET in LC. How do I fake a POST in LC
Posted: Thu Mar 15, 2012 5:14 am
Hi all,
I've just been catching up on some research into lcServer and reading about the GET and POST methods.
I see I can fake a Get in Android (I think):
launch url "http://192.168.1.6/lcMLoginGET.lc?UserI ... W=LiveCode"
Is there a way to fake a POST?
Maybe using the binary functions of LC?
or in c#:
http://stackoverflow.com/questions/3463 ... -http-post
Or javascript:
Is there a way we could use either of these scripts to fake a POST in LC for Android?
I've just been catching up on some research into lcServer and reading about the GET and POST methods.
I see I can fake a Get in Android (I think):
launch url "http://192.168.1.6/lcMLoginGET.lc?UserI ... W=LiveCode"
Is there a way to fake a POST?
Maybe using the binary functions of LC?
or in c#:
http://stackoverflow.com/questions/3463 ... -http-post
Code: Select all
string var1 = "Foo";
string var2 = "Bar";
ASCIIEncoding encoding = new ASCIIEncoding();
string post = "var1=" + var1 + "&var2=" + var2;
byte[] bites = encoding.GetBytes(post);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://Url/PageToPostTo.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bites.Length;
Stream s = request.GetRequestStream();
s.Write(bites, 0, bites.Length);
s.Close();
Code: Select all
function makeRequest(message,url,responseFunction){
var http_request;
if (window.XMLHttpRequest){ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject){ // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
http_request.onreadystatechange = responseFunction;
http_request.open("POST", url);
http_request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
http_request.send(message);
}