We create the correct JSON data, set that as the body of the POST request, and also set the headers correctly so that the server that receives this request will understand what we sent:
- Basically the idea is to set the request to be a POST request.
- Set the json-encoded data to be the body.
- Set the correct headers to describe that post body.
CURLOPT_RETURNTRANSFERis purely so that the response from the remote server gets placed in $result rather than echoed.
This content has been helpful to you?
Thanks for contributing!