- Joomla version 3.6.2
- com_api plugin (ac_api_installer_v1.8.5.zip)
Installation steps
- Upload extension zip file to install the plugin.
- Click on "Components" → "Api" → "API Keys", click on "New" button at "API Keys" page to launch "Add New Key" page
- Click "User" button to add an user, click "Save & Close" button to dismiss the page. API key for the selected user is generated.
- . Source code below is use to call "users" api from com_api, response in json format is returned
<?php
$url="http://localhost/home/index.php?option=com_api&format=raw&app=users&resource=users&key=08a3ffdf9243bc883849e689c3749293";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$resp = curl_exec($ch);
print_r($resp);
// Close request to clear up some resources
curl_close($ch);
- Source code below is use to call "login" api from com_api, response in json format is returned
<?php
$url="http://localhost/home/index.php?option=com_api&format=raw&app=users&resource=login&key=08a3ffdf9243bc883849e689c3749293";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
$html = curl_exec($ch);
print_r($html);
curl_close($ch);
- Source code below is use to call "config" api from com_api, response in json format is returned
<?php
$url="http://localhost/home/index.php?option=com_api&format=raw&app=users&resource=config&key=08a3ffdf9243bc883849e689c3749293";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$html = curl_exec($ch);
print_r($html);
curl_close($ch);
No comments:
Post a Comment