Daily requests usage
-
lcollong
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
7 years 2 months ago #6301
by lcollong
Hi Luigi,
I've succeed writing my own pluging for fetching data directly in SQL as I gave up making a generic Fabrik's list one.
However I've used Fabrik list prefiltering feature to very quickly create a menu showing only users own keys as per my request in another thread. All these extensions are doing great to build amazing apps very easily !
I'm using key controlled to the api. The expiration date feature works well. It stops serving the api after the specified date (also it seems there are some mess with timecode as it stops working later than the displayed date/hour. But does not matter in our case).
I thought the Daily Requests option would allow to limit the number of requests by day for a given key. I've tried to setup it to 3. But it never limited me. Also the current hits in the statistics tab never increased. Did I understand wrongly ?
Finally, the log stopped record the key number under "key / user" column. Could it be related to the upgrade from community to regular version ? Is this because I use http header method to pass the key rather than as a parameter ?
Thanks
Laurent
Please Log in or Create an account to join the conversation.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
7 years 2 months ago #6305
by admin
Hi Laurent,
the problem with the timezone will be fixed soon for any extension. This problem with timezones arises every time I use the date function to generate the timestanp for now() and save it in the database. I will manage to refer any generated and saved data to UTC.
About your real problem, daily requests should work exactly how you assumed, and works using the values "current_day" and "current_hits" stored for each api key and updated for each request. So you could check if those 2 fields are updated for each request (on an endpoint that uses the api key).
Kind regards,
Luigi
Please Log in or Create an account to join the conversation.
-
lcollong
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
7 years 2 months ago #6310
by lcollong
Good news for the date. Timezone management is a nightmare :-')
As you can see in the snapshots, the total hits, last use date and current date are all updated. But the "hit of the day" has been updated only once to "1" and has never changed (nor "0" nor "2").
The same for the key. It is no longer updated.
As I say I do no longer pass the key in the url (aka endpoint/get/mymodule/myaction?api_key=123ABC). I use header "Authorisation"
May be the data to log are not correctly collected this way ?
If you wish, I can grant you credential access to my test site (private) ?
Please Log in or Create an account to join the conversation.
-
lcollong
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
7 years 2 months ago #6318
by lcollong
Hi Luigi,
I've finally made some investigations. What I suspect seems to be right. I changed this file : components/com_jbackend/views/request/view.html.php around line 100 to :
if ($enable_trace)
{
// Collect post-execution log information
$log['error'] = (int)($this->item['status'] == 'ko');
$log['error_code'] = ($log['error']) ? $this->item['error_code'] : '';
$log['user_id'] = JFactory::getUser()->id;
$log['key'] = $app->input->getString('api_key', '');
//_____________
if (isset($_SERVER['HTTP_AUTHORIZATION']) && $log['key'] == '')
{
$header_auth = explode(' ', $_SERVER['HTTP_AUTHORIZATION']);
if ($header_auth[0] === 'api_key') $log['key'] = $header_auth[1];
}
//_____________
$log['module'] = $app->input->getString('module', '');
$log['action'] = $app->input->getString('action', '');
$log['resource'] = $app->input->getString('resource', '');
$log['duration'] += microtime(true);
// Save log information
jBackendHelper::logRequest($log);
}
and now, keys are displayed in the log.
Two more questions :
Do you plan to add a filter on key value in the log view (back-end) as we have on "endpoint" or date (Search Tools) ?
Does jBackend support other languages ? If yes is there a french version or should I create it ?
Thanks
Please Log in or Create an account to join the conversation.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
7 years 2 months ago #6334
by admin
You are right, it's a bug in the hits management.
I am working on the next release right now, that will also fix some problems due to latest joomla version changes.
I will release the next version in a day or two. All active subscribers will receive an email.
Thanks for reporting it.
Kind regards,
Luigi
Please Log in or Create an account to join the conversation.
Time to create page: 0.163 seconds