I've created an action that calls a service. The action will be called by a cron task. I want to set this up so that ONLY the cron task can call the action. It's important that it can not be run by any other means (via HTTP, CURL request etc.).
Any ideas on how to do that?
UPDATED (I think this will work):
public function actionMethod()
{
$this->requireAjaxRequest();
$key = craft()->request->getParam('key');
if($key == 'random-string' && $_SERVER['REMOTE_ADDR'] == 'my-servers-ip-address') {
craft()->plugin_name->actionMethod();
}
}
Note, this is twinned with a cron tab that looks like:
curl -H "X-Requested-With: XMLHttpRequest" http://sitename.co.uk/actions/plugin_name/Method?key=random-string