Peter had a great idea for a new feature in BANano:
A note beforehand: It is always an Ajax POST command, using JSON to do the communication. This may be extended in the future.
Some new settings one can set in AppStart:
A very simple example using the new CallInlinePHPWait() method. All we have to pass is the php method name, and a Map with key pairs where: the key is the parameter name and the value the parameter value.
When Building the BANano app, an extra php file will be generated. All one has to do is copy this php file to e.g. a WAMPs /www/ folder et voila: both are talking with each other .
An example of a generated php file:
I personally still favour using B4J's jServer to handle all my server related things (it is really powerful and has proven to be quite a bit faster than e.g. php), but if someone needs a BANano solution that just can't affort to use a VPS, there is now an alternative.
BANano 1.27 can be downloaded here: https://www.b4x.com/android/forum/threads/banano-progressive-web-app-library.99740
Alain
I liked it! He had already written out the ground rules so we only needed a couple of mails to get on the same page. As a result BANano 1.27 has a PHP connection (we plan support for .asp(x), CGI, python, ... later).Kiffi said:Hello Alain,
So you don't get bored , I have an idea for another BANano killer feature: ServerCode
Imagine, it would be possible to write BANano code that could be used to program on both the client and server sides. Code blocks to be executed on the server side are bracketed with #If #End If (like JavaScript blocks).
...
A note beforehand: It is always an Ajax POST command, using JSON to do the communication. This may be extended in the future.
Some new settings one can set in AppStart:
B4X:
BANano.PHP_NAME = "myapi.php"
BANano.PHPHost = "http://localhost"
BANano.PHPAddHeader("Access-Control-Allow-Origin: *")
A very simple example using the new CallInlinePHPWait() method. All we have to pass is the php method name, and a Map with key pairs where: the key is the parameter name and the value the parameter value.
B4X:
public Sub ButtonClicked(event As BANanoEvent)
' function name and params are Case Sensitive!
Dim res As String = BANano.CallInlinePHPWait("SayHello", CreateMap("Name": "BANano"))
log(res)
End Sub
' a simple php method which says hello!
#if PHP
function SayHello($Name) {
$ret = Array("answer" => "Hello " .$Name. "!");
echo json_encode($ret);
}
#End If
When Building the BANano app, an extra php file will be generated. All one has to do is copy this php file to e.g. a WAMPs /www/ folder et voila: both are talking with each other .
An example of a generated php file:
B4X:
<?php
header("Access-Control-Allow-Origin: *");
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
$request='';
if(isset($_POST['request'])){
$request = $_POST['request'];
$params = $_POST['params'];
}
if (!function_exists($request)) die("invalid request: '" . $request . "'");
function SayHello($Name) {
$ret = Array("answer" => "Hello " .$Name. "!");
echo json_encode($ret);
}
$values = array_values($params);
call_user_func_array($request, $values);
?>
I personally still favour using B4J's jServer to handle all my server related things (it is really powerful and has proven to be quite a bit faster than e.g. php), but if someone needs a BANano solution that just can't affort to use a VPS, there is now an alternative.
BANano 1.27 can be downloaded here: https://www.b4x.com/android/forum/threads/banano-progressive-web-app-library.99740
Alain
Last edited: