$data = array(“name” => “Hagrid”, “age” => “36”);
$data_string = json_encode($data);
$ch = curl_init(‘http://api.local/rest/users’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($data_string))
);
$result = curl_exec($ch);
curl_close();
get $GLOBALS[“HTTP_RAW_POST_DATA”];
Similar Posts:
- failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
- file_get_Contents and fopen return false when requesting HTTPS address: Error content: SSL routes: ssl3_get_server_certificate:certificate verify failed
- How to Solve Curl pass large JSON files Error
- Postman reported an error unsupported media type [How to Solve]
- [Solved] K8s cannot delete the namespace. It is always in the terminating state.
- [Solved] ElasticSearch Error: FORBIDDEN/12/index read-only/allow delete (api) ,read_only_allow_delete Set windows
- How to Use Array.prototype.slice.call(arguments)
- Error 77 when solving PHP curl HTTPS
- Uncaught typeerror: the solution of illegal invocation problem
- [Solved] Java.io.EOFException: No content to map to Obje…