eCommerce construction > How-to questions

Task.php, Task API Key and tsk Documentation

(1/2) > >>


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: 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:

--- Code: ---// 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.');

--- End code ---

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.


Please check your task api key in the settings (see screenshot).
it must be set to run task via cron.


Sigh  ??? That is all you have to say after everything I wrote?

Of course I entered a TASK API KEY in the settings.


--- Quote from: dhigz on December 08, 2020, 02:24:59 PM ---abolabo,

Sigh  ??? That is all you have to say after everything I wrote?

Of course I entered a TASK API KEY in the settings.

--- End quote ---

are you sure?

--- Code: ---$task_api_key = $config->get('task_api_key');
--- End code ---
This row means you do not have it when try to run via cli.
Please check it in the database table "settings"... or just in the code


You have always been a great help to me. But, respectfully, I think you may have missed the problem I was trying to point out.

1. The documentation says to use the task.php file with CRON.
2. The task.php file requires the use of the task_api_key (which does need to be entered on the settings API page) and verifies the task api key is passed to the task.php file in order to run without error (see line 67 of task.php file).
3. CRON does not allow you to pass the task key variable in the file name and the task.php file does not have provisions to interpret any command parameters sent from CRON.

To sum it all up: No matter what I have tried I have not been able to successfully run task.php from CRON as it states in the documentation.

As I initially stated, I am currently using task_api.php in order to run the task fro CRON. The use of task_api.php is not even discussed in the documentation for setting up CRON.

What I am asking for is 1) a how to answer to number 3 above or 2) address the documentation discrepancy and/or 3) fix the task.php file.


[0] Message Index

[#] Next page

Go to full version
Powered by SMFPacks Social Login Mod