Reputation: 21
i want to send data with Twebbrowser into web which receive by php $_post methode, then show it on webbrowser as webpage. this code is work perfectly in my vcl application
uses
httpapp;
Var
strData: string;
PostData: OleVariant;
Headers: OleVariant;
i: Integer;
url:string;
begin
url :='http://www.abc...com'
strData := 'id=' + HTTPEncode('ID') + '&' +
'ik=' + HttpEncode('ID2');
PostData := VarArrayCreate([0, Length(strData) - 1], varByte);
for i := 1 to Length(strData) do
PostData[i-1] := Ord(strData[i]);
Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
WebBrowser1.Navigate(url+'/logs.php',EmptyParam,EmptyParam,PostData,Headers);
end;
But when i try it for fmx for android device application, it send me eror message "too many actual parameter" on webbrowser.navigate. how can i post data with fmx webbrowser for fmx / android application ?
Upvotes: 1
Views: 1303
Reputation: 865
You can create your own html that includes the forum and post action and have javascript that auto-posts the form for you and then just call TWebBrowser.LoadFromStrings to load the html from a string var.
MyWebBrowser.LoadFromStrings({$I 'html\string_login_by_code.html.inc'},strSiteBaseURL);
And the "html\string_login_by_code.html.inc" file would look like:
'<HTML><HEAD></HEAD><BODY>'+
'<script>'+
'window.onload = function() '+
' {'+
' document.getElementById("v_login").submit();'+
' }'+
'</script>'+
'<form id="v_login" style="display:none" method="post" action="'+PostURL+'">'+
'<input type="hidden" name="'+chUserName+'" value="'+sUserName+'">'+
'<input type="hidden" name="'+chPassword+'" value="'+sPassword+'">'+
'<input type="submit" class="menu_submit" value=" ">'+
'</form>'+
'</BODY></HTML>'
Upvotes: 1