OK,
I have a task set up. It works perfectly when run from the Schedule Tasks screen. It also works perfectly when run from the browser when adding ?task_api_key=[my key] to the url. What I cannot get to work is running the task.php from CRON.
Following the examples on CRON in the documentation:
https://abantecart.atlassian.net/wiki/spaces/AD/pages/15007901/Scheduled+Tasks#ScheduledTasks-CRON for my Plesk server CRON will run the Task.php script but I get a response of: "Authorize the Access".
Looking at the task.php code it is clear this message is coming from the following:
// add to settings API et task_api_key
$task_api_key = $config->get('task_api_key');
if (!$task_api_key || $task_api_key != (string)$_GET['task_api_key']) {
exit('Authorize to access.');
}
What is clear is that running the command in CRON per the documentation does not work and to get it to work requires the task_api_key to be sent. However, there is no mention or explanation on how to do this.
My attempts at different methods to send the key have all failed. I attempted adding parameters to the file name gave a could not open file error. Passing the key value pair as an argument open the file but gave me the "Authorize the Access" error.
The only way I can successfully run the task.php file from CRON is to remove the $_GET requirement from the is statement.
What does work and I am doing for now is to direct CRON to the task_cli.php file instead. Problem is there is no API Key security. Using task_cli.php is not even mentioned on this documentation page.
My point of this post is that something needs to be fixed so others do not have their time wasted as mine was today.
- Tell me how to pass the task api parameter for I can use task.php.
- Fix task.php so it recognizes an argument value and not just $_GET.
- Fix the documentation.
I am ready to release a new extension and this is the only thing holding me up. I do not want to mislead people by sending them to misleading documentation. If there is an answer to #1, I would sure like to know it.
Thanks