Created
November 11, 2019 03:41
-
-
Save chetanmadaan/9bdee570fc8ce86df694932248be32dd to your computer and use it in GitHub Desktop.
Access Single article - 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'; | |
// ID of the article you want to access | |
$articleid = 6; | |
// No Edits below this line needed. | |
$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 => "GET", | |
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