Need a PHP script to validate API POST

Currently I am using Postmam to check and validate the API credentials, would like to know if anyone can provide me a simple PHP script to do a POST to an API endpoint and to display the response.

The method is POST

URL: https://domain.com/apiupdate

Authorization ->
basic Auth
username
password

HEADER:
Content-Type: application/json
X-Gateway-APIKey:

BODY:

{“updateDate” : “20180203”,
“roomsOccupied” : “3”,
“roomsAvailable” : “10”,
“roomsBooked” : “2”,
“roomsOnMaintenance” : “2”,
“channel” : “XYZ”}

Use CURL, PHP has native functions for that, just look at the manual. Also the Guzzle library may be usefull, you find it on Github

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service