Created
November 11, 2019 04:27
-
-
Save chetanmadaan/ce1e40da45c1481dcb915dc898e5dcea to your computer and use it in GitHub Desktop.
Delete article via Joomla 4 API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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