ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #1 When sending a PostString request using jOkHTTPUtils2 a PHP Echo response can be shown in the PHP script on the server. The problem is that I have to send a separate request just to get a response value from Echo, and then send another Request to another PHP script to do whatever to be done, depending if the first script returns for example True or False. Is there a way to get the response from Echo in GetString and handle the second action within the same process? I can illustrate this in a sequence: 1. send a job to the server. 2. the first PHP script returns a response using Echo. 3. if GetString receives True then we calls 4 4. Send a new job to call the second PHP script Perhaps this can be dealt with differently?
When sending a PostString request using jOkHTTPUtils2 a PHP Echo response can be shown in the PHP script on the server. The problem is that I have to send a separate request just to get a response value from Echo, and then send another Request to another PHP script to do whatever to be done, depending if the first script returns for example True or False. Is there a way to get the response from Echo in GetString and handle the second action within the same process? I can illustrate this in a sequence: 1. send a job to the server. 2. the first PHP script returns a response using Echo. 3. if GetString receives True then we calls 4 4. Send a new job to call the second PHP script Perhaps this can be dealt with differently?
OliverA Expert Licensed User Longtime User Mar 20, 2019 #2 ThRuST said: When sending a PostString request using jOkHTTPUtils2 a PHP Echo response can be shown in the PHP script on the server. The problem is that I have to send a separate request just to get a response value from Echo Click to expand... You do? Odd, have you tried it on the B4J side? Where is your code. Even with POSTing, the GetString function should still contain the response given by the server, unless the response code is not 200 (j.success = False). Upvote 0
ThRuST said: When sending a PostString request using jOkHTTPUtils2 a PHP Echo response can be shown in the PHP script on the server. The problem is that I have to send a separate request just to get a response value from Echo Click to expand... You do? Odd, have you tried it on the B4J side? Where is your code. Even with POSTing, the GetString function should still contain the response given by the server, unless the response code is not 200 (j.success = False).
DonManfred Expert Licensed User Longtime User Mar 20, 2019 #3 I would just do PHP Script 1 do all the work (including calling the second one) Upvote 0
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #4 @OliverA yes I tried this in B4J. The challenge in this is to send back a second Echo to GetString from the first job depending on what the PHP script should do. @DonManfred Nice implementation. If I can just figure out a way in which sequence Echo can return a response to the application. Possibly multiple Echo responses can be handled from the first job. Upvote 0
@OliverA yes I tried this in B4J. The challenge in this is to send back a second Echo to GetString from the first job depending on what the PHP script should do. @DonManfred Nice implementation. If I can just figure out a way in which sequence Echo can return a response to the application. Possibly multiple Echo responses can be handled from the first job.
OliverA Expert Licensed User Longtime User Mar 20, 2019 #5 ThRuST said: The challenge in this is to send back a second Echo to GetString from the first job depending on what the PHP script should do Click to expand... Are you in control of the PHP scripts? Why would you send two "Echo"'s? You process the info on the server, and then you send back one message. Plus, if the same server has to just act on he outcome of the first POST, why not just act on the first post on the server side (as per @DonManfred )? Upvote 0
ThRuST said: The challenge in this is to send back a second Echo to GetString from the first job depending on what the PHP script should do Click to expand... Are you in control of the PHP scripts? Why would you send two "Echo"'s? You process the info on the server, and then you send back one message. Plus, if the same server has to just act on he outcome of the first POST, why not just act on the first post on the server side (as per @DonManfred )?
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #6 I guess I should find some examples how to write improved PHP scripts. The process of what worked for me was something I wanted to share to have a chance to learn other (better) methods. I should plan out how the PHP scripts should work so I guess the answer is that I need to level up my PHP skills which turned a bit rusty. Any further advice how to have GetString receive a second Echo string is highly appreciated since it can open up for enhancements. Upvote 0
I guess I should find some examples how to write improved PHP scripts. The process of what worked for me was something I wanted to share to have a chance to learn other (better) methods. I should plan out how the PHP scripts should work so I guess the answer is that I need to level up my PHP skills which turned a bit rusty. Any further advice how to have GetString receive a second Echo string is highly appreciated since it can open up for enhancements.
DonManfred Expert Licensed User Longtime User Mar 20, 2019 #7 - One HTTP-Call can only get one Response. - The PHP could return a json Structure with any amount of values. Upvote 0
- One HTTP-Call can only get one Response. - The PHP could return a json Structure with any amount of values.
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #8 @DonManfred Awesome, that saved my day (and others as well), Thanks a bunch Upvote 0
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #9 @DonManfred Are you familiar with any json posts you might link to for the second alternative related to this would be super. Upvote 0
@DonManfred Are you familiar with any json posts you might link to for the second alternative related to this would be super.
DonManfred Expert Licensed User Longtime User Mar 20, 2019 #10 I´m not sure that i understand the question Upvote 0
OliverA Expert Licensed User Longtime User Mar 20, 2019 #11 Take a look at this post by @KMatle for insights/inspiration: https://www.b4x.com/android/forum/t...tputils2-part-3-php-mysql-json.42663/#content Upvote 0
Take a look at this post by @KMatle for insights/inspiration: https://www.b4x.com/android/forum/t...tputils2-part-3-php-mysql-json.42663/#content
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #12 @DonManfred I found a post about json and PHP here Sorry for the confusion. Upvote 0
DonManfred Expert Licensed User Longtime User Mar 20, 2019 #13 PHP: Copy $appversion = array(); $appversion["Version"] = APPVERSION; $appversion["Name"] = "KvTools"; $appversion["DeviceID"] = $DeviceID; $appversion["Token"] = $token; echo json_encode($appversion); PHP: Copy $sql = "SELECT * FROM `table` t "; $logged = $db->rawQuery($sql, null); # mySQLi-Class echo json_encode($logged); Last edited: Mar 21, 2019 Upvote 0
PHP: Copy $appversion = array(); $appversion["Version"] = APPVERSION; $appversion["Name"] = "KvTools"; $appversion["DeviceID"] = $DeviceID; $appversion["Token"] = $token; echo json_encode($appversion); PHP: Copy $sql = "SELECT * FROM `table` t "; $logged = $db->rawQuery($sql, null); # mySQLi-Class echo json_encode($logged);
ThRuST Well-Known Member Licensed User Longtime User Mar 20, 2019 #14 @DonManfred Very impressive. A master at work Upvote 0