- Posts: 5
- Thank you received: 0
Please Log in or Create an account to join the conversation.
To avoid to pass credentials in clear it is recommended to expose the endpoint over HTTPS, and to pass username and password as POST variables (it is supported out-of-the-box).
Please Log in or Create an account to join the conversation.
public function actionGetItems(&$response, &$status = null)
{
$app = JFactory::getApplication();
// Get additional request parameters
$id = $app->input->getInt('id');
if (!is_null($id))
{
// Example of how to generate and return an error inside an action function
if ($id == '101')
{
$response = plgJBackendHelloWorld::generateError('HWD_GEN'); // Generic hello world error
return false;
}
}
// Get the data
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Structure a query joomla stylee
$query->select($db->quoteName(array('id', 'itemtitle', 'deliverydestination', 'updated', 'status', 'item_image')));
$query->from($db->quoteName('#__items'));
$query->where($db->quoteName('status') . ' LIKE '. $db->quote('Collecting Bids'));
$query->order('updated DESC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$requests = $db->loadObjectList();
if (empty($requests))
{
return 'HWD_DAT'; // Article not found
}
// Get plugin params - what could we do with this?
// $option_name = $this->params->get('option_name', 0);
$response['status'] = 'ok';
$response['total'] = count($requests);
// Do we do pagination in the response or return everything?
// $response['limit'] = $pagination->limit;
// $response['offset'] = $pagination->limitstart;
// $response['pages_current'] = $pagination->pagesCurrent;
// $response['pages_total'] = $pagination->pagesTotal;
//$response['items'] = array();
foreach ($requests as $request)
{
$request = array();
$item['id'] = $request->id;
$item['title'] = $request->itemtitle;
$item['alias'] = $request->alias;
$item['status'] = $request->status;
$item['created_by'] = $request->created_by;
$response['requests'][] = $item;
}
if ($option_name)
{
$response['option'] = 'true';
}
return true;
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.