I'm a newbie, I have a project which needs to send daily reminders to users. I see that you can do this using cron jobs. However, I need to call the API which has the daily reminder. This API is an external one. How do I do that?
UPATE: I need to invoke the API and then get the response and send email to users daily.
Curl is your friend. In your case, you would have something like this:
0 8 * * * curl -X POST -d '{"message":"content"}' apidomain.com/endpoint/
In my example, I specify POST even though curl will default to a POST when you specify data (with the -d option). I've included it in case your API expects a different HTTP method like GET or PUT.
The curl manpage will help: https://linux.die.net/man/1/curl
And see this answer for some help with JSON and curl: https://stackoverflow.com/a/7173011/1876622
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With