#1 2016-12-02 01:45:37

edunt
Member
Registered: 2015-12-21
Posts: 258

Help to find certain text/string that I found in my application

Hi,

Where can I find this text for modification? Because the message was sent successfully without any issue. But the message is misleading

Untitled.png

Thanks

Last edited by edunt (2016-12-02 01:54:26)

Offline

#2 2016-12-02 09:27:48

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Help to find certain text/string that I found in my application

Hello Ade,

If I am not wrong you are using some modified code of the Calculator sample. The error message that you shown above is in the Calculator's Comments view, more specifically in the HttpClient control Error event. This is the code around:

// This status code meant the feedback data (email) are not valid
If "[HttpClient.Status]" "==" "406"
  AlertBox "Please, be sure the feedback information is valid." "warning"

// This status code meant the PHP mail function fail for some reason
ElseIf "[HttpClient.Status]" "==" "500"
  AlertBox "Sorry, a server error occur and the feedback cannot be send. Try again in a couple of minutes!" "warning"

// Other possible errors
Else
  AlertBox "Sorry, an unknow error occur. Status: [HttpClient.Status] - Status text: [HttpClient.StatusText]" "warning"
EndIf

So, the error message appear if the Http status code is "500", and, at least in the above code, don't appear in any other case.

Offline

#3 2016-12-02 12:27:21

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Help to find certain text/string that I found in my application

David wrote:

Hello Ade,

If I am not wrong you are using some modified code of the Calculator sample. The error message that you shown above is in the Calculator's Comments view, more specifically in the HttpClient control Error event. This is the code around:

// This status code meant the feedback data (email) are not valid
If "[HttpClient.Status]" "==" "406"
  AlertBox "Please, be sure the feedback information is valid." "warning"

// This status code meant the PHP mail function fail for some reason
ElseIf "[HttpClient.Status]" "==" "500"
  AlertBox "Sorry, a server error occur and the feedback cannot be send. Try again in a couple of minutes!" "warning"

// Other possible errors
Else
  AlertBox "Sorry, an unknow error occur. Status: [HttpClient.Status] - Status text: [HttpClient.StatusText]" "warning"
EndIf

So, the error message appear if the Http status code is "500", and, at least in the above code, don't appear in any other case.

Hi,

Yes, I am using the idea of sample calculator feedback and I created a new project for collecting data from mobile to email.

However, the issue I am having is each a message is sent this error "Sorry, a server error occur and the feedback cannot be send. Try again in a couple of minutes!" display.

Although, the message is successfully sent and received in the email and this message suppose to display "Thanks!" "I will contact you if needed. Thanks again!"

I think HTTPClient component need an update.

Could you please have a look at it.

AB Rock Ninja!

Offline

#4 2016-12-02 12:32:27

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Help to find certain text/string that I found in my application

Hello Ade,

If what are you based to say "I think HTTPClient component need an update."? I don't think so. The "error" message that you are talking about don't appear from the nothing: such error message must exists in your own code in order to appear!

So maybe you place that message in a wrong place. Or some mistake in your code can be also the cause of the problem. Since I don't know nothing about your code I can't help you in that part.

However, if the "HTTPClient component need an update" then the proper Calculator sample (in which you based your code) fails with the same error... and that's is not the case, as you can see if try it.

I sincerely supose some mistake in your app's code. In the client side, the server side or both places.

Offline

#5 2016-12-02 12:44:49

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Help to find certain text/string that I found in my application

David wrote:

Hello Ade,

If what are you based to say "I think HTTPClient component need an update."? I don't think so. The "error" message that you are talking about don't appear from the nothing: such error message must exists in your own code in order to appear!

So maybe you place that message in a wrong place. Or some mistake in your code can be also the cause of the problem. Since I don't know nothing about your code I can't help you in that part.

However, if the "HTTPClient component need an update" then the proper Calculator sample (in which you based your code) fails with the same error... and that's is not the case, as you can see if try it.

I sincerely supose some mistake in your app's code. In the client side, the server side or both places.

I just realised now that, you are right, the HTTPClient doesn't need update at the moment. I follow the calculator sample feedback idea, it show error too, although I have tested it on another server and the still dispaly.

Offline

#6 2016-12-02 12:54:32

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Help to find certain text/string that I found in my application

Hello Ade,

edunt wrote:

I just realised now that, you are right, the HTTPClient doesn't need update at the moment. I follow the calculator sample feedback idea, it show error too, although I have tested it on another server and the still dispaly.

The Calculator sample ONLY shown that error if the server side response status code is 500. And this only happend if the PHP "mail" function doesn't work as expected. If you receive such error some times, then you know the cause of the error: the "mail" function doens't work as expected. In any other case you can receive that error with the Calculator sample: at least using the provided PHP script.

And this last is the important question... are you modified the PHP script? How? Are you modified the Calculator feedback related code? And how? Take a look at the PHP script that we are talking about, just like is placed right now in my hosting and you can found in the Calculator sample inside the "Server" directory:

<?php

// Enable CORS (http://enable-cors.org/server_php.html)
header('Access-Control-Allow-Origin: *');

// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
    header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
  if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
    header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
  exit;
}

// Recolect and validate the input data
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS);
$comments = filter_input(INPUT_POST, 'comments', FILTER_SANITIZE_SPECIAL_CHARS);

// Test if the input data is valid
if (($email !== false) && ($name !== false) && ($comments !== false)) {

  // Prepare our mail message
  $message = sprintf("%s <%s>\n\n%s", $name, $email, $comments);

  if (mail('info@davidesperalta.com', 'App Builder Calculator Feedback', $message)) {
    // Mail sent
    http_response_code(200);
  } else {
    // mail function fail!
    http_response_code(500);
  }
} else {
  // Invalid input data
  http_response_code(406);
}

Can you see that we only answer with a "500" status code if the "mail" function doesn't work as expected? Now take a look at the HttpClient Error event used in the Calculator sample Comments view:

// The request end with error
Hide "Progressbar"

// This status code meant the feedback data (email) are not valid
If "[HttpClient.Status]" "==" "406"
  AlertBox "Please, be sure the feedback information is valid." "warning"

// This status code meant the PHP mail function fail for some reason
ElseIf "[HttpClient.Status]" "==" "500"
  AlertBox "Sorry, a server error occur and the feedback cannot be send. Try again in a couple of minutes!" "warning"

// Other possible errors
Else
  AlertBox "Sorry, an unknow error occur. Status: [HttpClient.Status] - Status text: [HttpClient.StatusText]" "warning"
EndIf

// Focus the first input
Focus "NameInput"

Can you see that we only shown the "error" message if the status code is "500"? Then the Calculator sample works as expected, and only shown that "error" if the server side return an status code "500". Never in other case.

Offline

#7 2016-12-02 15:56:49

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Help to find certain text/string that I found in my application

David wrote:

Hello Ade,

The Calculator sample ONLY shown that error if the server side response status code is 500. And this only happend if the PHP "mail" function doesn't work as expected. If you receive such error some times, then you know the cause of the error: the "mail" function doens't work as expected. In any other case you can receive that error with the Calculator sample: at least using the provided PHP script.

I understand the reason for the error.

David wrote:

And this last is the important question... are you modified the PHP script? How? Are you modified the Calculator feedback related code? And how? Take a look at the PHP script that we are talking about, just like is placed right now in my hosting and you can found in the Calculator sample inside the "Server" directory.

Yes, the PHP was modified to suit my needs.

Taken the post.php from the sample folder modify the script and uploaded to my webserver then I use the url of post.php from my webserver inside HTTPClient component so that the component can point to the file

Yes, I modified the Calculator feedback related.

David wrote:

Can you see that we only answer with a "500" status code if the "mail" function doesn't work as expected? Now take a look at the HttpClient Error event used in the Calculator sample Comments view:

Yes, only the "500" status code, message display after send button is pressed.

David wrote:

Can you see that we only shown the "error" message if the status code is "500"? Then the Calculator sample works as expected, and only shown that "error" if the server side return an status code "500". Never in other case.

Yes, I understand it. But for unknown reason the message always display.

Offline

#8 2016-12-02 16:00:28

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Help to find certain text/string that I found in my application

Hello Ade,

Ade wrote:

Yes, I understand it. But for unknown reason the message always display.

I try to help you Ade, but, without a way to reproduce a possible problem there is very difficult. My recomendation is to start from the scratch, that is, start with the Calculator sample, and then try to prepare the "feedback" stuff in an "alone" application. Once you get it working you can try to implement the appropiate stuff into your application. If you need any help in the meanwhile just post here.

Offline

#9 2016-12-02 19:44:14

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Help to find certain text/string that I found in my application

David wrote:

Hello Ade,

Ade wrote:

Yes, I understand it. But for unknown reason the message always display.

I try to help you Ade, but, without a way to reproduce a possible problem there is very difficult. My recomendation is to start from the scratch, that is, start with the Calculator sample, and then try to prepare the "feedback" stuff in an "alone" application. Once you get it working you can try to implement the appropiate stuff into your application. If you need any help in the meanwhile just post here.

Hi,

Thanks for your advise. I started the project from the scratch and only use the PHP script came with AB (Calculator "Feedback"). I just have a look at how you did it in Calculator - Feedback.

Last edited by edunt (2016-12-02 19:45:10)

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.