---
description: >-
  https://www.cloudways.com/blog/setup-basic-authentication-in-wordpress-rest-api/
---

# \[API] Gửi yêu cầu XÓA đến một cài đặt WordPress khác với API REST của WordPress

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MOKtcuE6aPF7_eZqom9%2F-MOKvQaJdMHSpNwEaM_D%2FScreenshot_1.png?alt=media\&token=abcaee51-0756-4d80-9924-1a350b94e58e)

```
<?php
$wp_request_headers = array(
  'Authorization' => 'Basic ' . base64_encode('wordpress:wordpress'),
);
$wp_request_url          = 'http://localhost/api/wp-json/wp/v2/posts/12';
$wp_delete_post_response = wp_remote_request(
  $wp_request_url,
  array(
    'method'  => 'DELETE',
    'headers' => $wp_request_headers
  )
);
echo wp_remote_retrieve_response_code($wp_delete_post_response) . ' ' . wp_remote_retrieve_response_message($wp_delete_post_response);
?>
```
