Skip to content

Instantly share code, notes, and snippets.

@chetanmadaan
Created November 11, 2019 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chetanmadaan/ce1e40da45c1481dcb915dc898e5dcea to your computer and use it in GitHub Desktop.
Save chetanmadaan/ce1e40da45c1481dcb915dc898e5dcea to your computer and use it in GitHub Desktop.
Delete article via Joomla 4 API
<?php
// Enter the path of your Joomla site.
$baseurl = 'http://localhost/j4a12';
// Joomla Super Admin Credentials
$user = 'admin';
$pass = 'admin';
// Article id to Delete
$articleid = 15;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $baseurl."/api/index.php/v1/content/article/".$articleid,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Accept: */*",
"Accept-Encoding: gzip, deflate",
"Authorization: Basic ".base64_encode($user.':'.$pass),
"Cache-Control: no-cache",
"Connection: keep-alive",
"Content-Type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment