I have found a couple of helpful links on stackoverflow but they haven't helped me complete my task because I am a complete beginner in trying to write PHP or use curl etc.
Posting JSON data to API using CURL
I have been using Postman in Chrome to test API calls but I now want to put together a demo system on my Apache web server.
Does anyone have an example of a PHP webform posting to a json Object to a REST API?
Here is an example of what I want to send:
<?php
$url = "https://api.url/api/v1//accounts/create";
$jdata = json_encode($data);
$data = [{
"status": "active",
"username": ["uname"],
"password": ["pword"],
"attributes": {
"forenames": ["fname"],
"surname": ["lname"],
"emailAddress": ["email"]
},
}]
?>
Any advice would be fantastic. Like I said, I am new to curl and php, am unfamiliar with the array approach mentioned in the other articles and the ["info"] elements should be populated with the information filled in on my webform.
I hope I have been concise and explanitory but please let me know if you need anymore information.
Snook