How to call the php interface in java: first use PostMethod to create a request method and set the header parameters; then set the parameter values to be passed during the request process; then execute the request method to return the code; finally encapsulate the return result. .
How java calls the php interface:
1. First create a request method, let’s make a judgment first. Encoding format, as shown in the figure
Related learning recommendations:java basic tutorial
2. Then create a request The method used here is PostMethod, as shown in Figure
#3, and then set the header parameters. PHP only works when the content-type is application/x-www-data-urlencoded and multipart The parameters in the two cases of /form-data are as shown in the figure
4. Set the parameter values to be passed during the request process, as shown in the figure
5. Then execute the request method and return the code
6. Finally, encapsulate the return result, and then you can call this method and pass in the PHP interface address. , as shown in the figure
Related learning recommendations:php programming(video)
The above is the detailed content of What is the method for java to call php interface?. For more information, please follow other related articles on the PHP Chinese website!