What should I do if I want to implement communication between the php server and the android client and both parties transmit json data? {Code...} the android client can receive the sent json data, but the server does not seem to be able to receive it. The android client can receive the data sent by the server .. You guys... What should I do if I want to implement communication between the php server and the android client and the two parties transmit json data?
$reciver=file_get_contents('php://input'); 5 //echo $reciver; 6 7 8 if(!empty($reciver)) 9 { 10 $reciver=json_decode($reciver); 11 12 $code='200'; 13 $message='I have receiver it'; 14 $data='received'; 15 } 16 else 17 { 18 $code='400'; 19 $message='reciver bad'; 20 $data='not received '; 21 } 22 23 24 25 Response::responseResult 26 ($code,$message,$data);
The android client can receive the sent json data, but the server does not seem to be able to receive it. The android client can receive the data sent by the server ..
Thank you for your advice ..
Reply content:
What should I do if I want to implement communication between the php server and the android client and both parties transmit json data?
$reciver=file_get_contents('php://input'); 5 //echo $reciver; 6 7 8 if(!empty($reciver)) 9 { 10 $reciver=json_decode($reciver); 11 12 $code='200'; 13 $message='I have receiver it'; 14 $data='received'; 15 } 16 else 17 { 18 $code='400'; 19 $message='reciver bad'; 20 $data='not received '; 21 } 22 23 24 25 Response::responseResult 26 ($code,$message,$data);
The android client can receive the sent json data, but the server does not seem to be able to receive it. The android client can receive the data sent by the server ..
Thank you for your advice ..
Postman simulates sending data, and then outputs it to see the structure. Is it not easy to process the structure?
Capture the package and check whether the data has been transmitted.
View the data format and log
The server log prints the request to see the format of data sent by the client and then processes it.
It is best for the server client to check whether there is a problem with server reception and client sending. On the server side, you can use the postman plug-in the chorme browser to simulate sending requests to check whether your backend program is faulty. The client checks whether the request protocol address, parameters, and request method comply with the server-side protocol design. This problem is easy to find out.
Does your server jump? If no jump is made, your code will surely be available.
Check the request header of your client and use $ _ POST.
Android does not send the original post data packet and you cannot obtain it.
If this method is used, the Android client cannot submit a request using a form. Only JSON strings can be POST as request bodies.