Starting my first android app. How can I easily test if the server has received a message?

StackOverflow https://stackoverflow.com/questions/23689582

  •  23-07-2023
  •  | 
  •  

Вопрос

I am experienced with Java and have some experience with PHP (the server scripting language I will be using unless anybody tells me I shouldn't for some reason. I want to just send a string via POST to the server. Because there is not actually a webpage being created, I can't just echo the string if it is received. How should I test if the string was received by the server?

Edit: After further research, it seems like echo doesn't just print to a browser, it sends a string through the http connection to whatever is connected to the php page. I should then be able to echo a response and receive it through an input string on the Java end. Is this correct?

Это было полезно?

Решение

You could use echo, as you mentioned, but the more common and reusable method of debugging PHP as you progress is the use of error_log(). You can view its output on the PHP server in the php.log file, commonly found at /tmp/php.log.

You can watch this file in real-time via the Unix command tail -f /tmp/php.log.

Further, you can output various forms of data by calling it with print_r() like error_log(print_r($data, TRUE));.

Другие советы

I believe you should be properly sending back Responde codes in your php scripts.

Please check: How to send a status code in PHP and Android: How get the status-code of an HttpClient request.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top