Hi, I’m trying to delete a subscriber, using an API call to the ENDPOINT, using PHP. Here is my code:
<?php
$email = “john@email.com”;
$url = “websiteurl/newsletter/wp-json/newsletter/v2/subscribers/” . $email;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “DELETE”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
‘X-TNP-KEY: admin:123456’,
‘X-TNP-SECRET-KEY: 654321’
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if(curl_errno($ch)){
echo ‘Request Error:’ . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
______________________________________
All I get is this error:
{“code”: “rest_forbidden”, “message”: “You do not have permission to do so.”, “data”:{“status”:401}}
Why ?
Thank you!
Alex