PHP-Send HTTP Get/Post Request and Read JSON response

In this video I have shown you how you can send HTTP Get/Post request and Read JSON response using PHP.
Get request is demonstrated with help of ipinfodb.com and Post request is demonstrated using postman-echo.com.
The local server I am using is xampp server installed in windows pc.

1. HTTP GET Request.

First register in ipinfodb.com to get the API key for testing the http request.
The request and response in post man client is shown below.

IP address is taken from user as an input from HTML form in index.php. This data is submitted to form_get.php, Then the response is read and printed in the index.php after parsing the JSON value.

So we parsed the below json response,

After running the code in xampp server, It is shown below.

2. HTTP POST Request.

Code Post request is shown below. The same way we demonstrated the get request, we take the inputs from user side from the html form in index_post.php. Then the request is forwared to form_post.php to Post the request and read the response from the server.

The request and response in postman client is shown below.

So we parsed the below json response,

The index_post.php after running in server is shown below.

1,041 views