B4J Question [BANano] Inline php fails to open php file

toby

Well-Known Member
Licensed User
Longtime User
I followed the tutorial to create a simple app, testing the inline php feature. The only problem I'm having are that the app failed to open the php file and that the hello message didn't show.

Could someone show me how to make it working, please?

TIA

Web server for Chrome Console error:
Failed to load resource: net::ERR_CONNECTION_REFUSED   localhost/myapi.php
 

toby

Well-Known Member
Licensed User
Longtime User
My test project is based on BANano PWA project, plus following changes:

1. code added to App_Start:
Code added to beginning of App_Start:
    'for inline php script:
    BANano.PHP_NAME = "myapi.php"
    BANano.PHPHost = "http://localhost"
    BANano.PHPAddHeader("Access-Control-Allow-Origin: *")

2. Added a button skbtnHello to the WelcomePageLayout
3. Appended following code to the Main module
B4X:
Private Sub skbtnHello_Click (event As BANanoEvent)
    SKTools.ShowToast("enterieng skbtnHello_Click", "info", 3000, True)
    ' 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
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
The previous posts are about running on localhost using the Web Server for Chrome.

I just changed BANano.PHPHost to point to test app location, where myapi.php is located, on the remote vps server. I got 403 forbidden error when trying to call the SayHello().

Test url

Could someone tell me what I did wrong, please?

TIA
 
Upvote 0
Top