I have had some difficulty getting cron to run Amelia send notifications.
I followed the suggestions of setting up the system cron and when that did not work I tried WP Crontrol and added the suggested code to “Add PHP Cron Event”, this was also unsuccessful.
Using curl instead of file_get_contents does work on my site, but only if I add the option CURLOPT_USERAGENT, "Firefox 32.0". Scheduled notifications are now working.
Is there a more direct way to call Amelia to send the notifications, than using a url where I have to pretend that the request is coming from a browser?
It depends of your server you will need to have separate settings on your hosting provide (cPanel for settings this up)
Scheduled notifications require a bit of additional configuration with your server cron scheduler. The command that has to be added can be found on the “Notifications” page when notification that requires scheduling is active. You can recognize these notifications by the clock icon next to the notification name. Copy command and paste it in the cron file. The command looks like this:
You can see the more detailed tutorial how to set up cron at this link.
If you are not familiar with this you can use plugin WP Crontrol for creating cronjob.
In the Tools -> Cron Events admin panel,
click on the “Add PHP Cron Event” tab underneath the cron event table.
In the form that appears, enter the schedule and next run time in the boxes. The event schedule is how often your event will be executed. In the “PHP code” area, enter the PHP code that should be run when your cron event is executed. Please insert this:
You don’t need to provide the PHP opening tag (<?php).
Please replace "https://yourwebsite.com" with your real web address.
If you don’t see a good interval, then add one in the Settings -> Cron Schedules admin panel or click on link "Manage Cron Schedules". You will find example how you can make custom interval inserting:
Interval name
Interval(in seconds)
Display name
and click "Add Cron Schedules" and it will be added.
When you made custom interval you need to go back to Tools -> Cron Events admin panel and click on the “Add PHP Cron Event” tab underneath the cron event table where you will insert that custom interval and all other field that are described above. After clicking on "Add PHP Cron Event" it will be added on Event table and you are done.
If you have any confusion about this feel free to ask us, and we will help you.
So apparently my site requires the call to at least pretend to come from a browser.
My question was, Is there a more direct way to call Amelia to send the notifications, than using a url where I have to pretend that the request is coming from a browser?
I have had some difficulty getting cron to run Amelia send notifications.
I followed the suggestions of setting up the system cron and when that did not work I tried WP Crontrol and added the suggested code to “Add PHP Cron Event”, this was also unsuccessful.
I found that file_get_contents("https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send") always returned false. Even though I could paste the address into the browser and it would work fine and the reminder messages would be sent out.
Using curl instead of file_get_contents does work on my site, but only if I add the option CURLOPT_USERAGENT, "Firefox 32.0". Scheduled notifications are now working.
Is there a more direct way to call Amelia to send the notifications, than using a url where I have to pretend that the request is coming from a browser?
Hi David,
Thank you for your message.
It depends of your server you will need to have separate settings on your hosting provide (cPanel for settings this up)
Scheduled notifications require a bit of additional configuration with your server cron scheduler. The command that has to be added can be found on the “Notifications” page when notification that requires scheduling is active. You can recognize these notifications by the clock icon next to the notification name. Copy command and paste it in the cron file. The command looks like this:
*/15 * * * * https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send
You can see the more detailed tutorial how to set up cron at this link.
If you are not familiar with this you can use plugin WP Crontrol for creating cronjob.
In the Tools -> Cron Events admin panel,
click on the “Add PHP Cron Event” tab underneath the cron event table.
In the form that appears, enter the schedule and next run time in the boxes. The event schedule is how often your event will be executed. In the “PHP code” area, enter the PHP code that should be run when your cron event is executed. Please insert this:
You don’t need to provide the PHP opening tag (<?php).
Please replace "https://yourwebsite.com" with your real web address.
If you don’t see a good interval, then add one in the Settings -> Cron Schedules admin panel or click on link "Manage Cron Schedules". You will find example how you can make custom interval inserting:
and click "Add Cron Schedules" and it will be added.
When you made custom interval you need to go back to Tools -> Cron Events admin panel and click on the “Add PHP Cron Event” tab underneath the cron event table where you will insert that custom interval and all other field that are described above. After clicking on "Add PHP Cron Event" it will be added on Event table and you are done.
If you have any confusion about this feel free to ask us, and we will help you.
Best regards.
Hi Den
You did not actually answer my question, instead you just listed what can be found elsewhere on your website that I said I have already tried.
First of all, I don't know why you suggest putting */15 * * * * https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send in the system cron, when cron can't call a url. You will most likely need to use wget or curl to call the url in cron.
I also said I could not get file_get_contents() to work. This is specific to my site, but is not entirely uncommon from what I have read.
What did work was using the following replacement for file_get_contents(). I found this at https://stackoverflow.com/questions/25827167/file-get-contents-returns-false
The important part in my case was the lineSo apparently my site requires the call to at least pretend to come from a browser.
My question was, Is there a more direct way to call Amelia to send the notifications, than using a url where I have to pretend that the request is coming from a browser?
Hi David,
I will clarify your question with the tech team, will get back to you on that later this week.