curl -X GET --user username:password -i http://yourdomain.com/wp-json/wp/v2/posts?status=draft
$ch = curl_init();
$url = "http://yourdomain.com/wp-json/wp/v2/posts?status=draft";
$postfields = ['user' => 'admin:password'];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
echo curl_exec($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://yourdomain.com/wp-json/wp/v2/posts?status=draft');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);