How do I set up a scheduled API call on a website?

I'm just getting a little bit about APIs and I just wanted to figure out how I can schedule the API to automatically invoke a specific call. The situation I would like to solve is this: I am using SendGrid to help me deliver mail from a contact form on my website, but I noticed that some emails are not delivered, but persist on the sendgrid servers for 7 days ... I would like to use their API to store all email records in a database on my website so that I can look through them every time so often to see if there are any emails that have not gone through yet.

The only way I know how to do this is to create a website like this:

$records = connection_to_sendgrid_database;
foreach ($records as $record) {
    if ($record->id is not in this database) {
        add the whole record into the database;
    }
}

      

And then I will have to visit this page every 7 days to make sure I get all the email records.

I am sure the best way to do this. Unfortunately, I don't know much about programming applications that can do this for me, but it seems like automatic API calls should be something that has been done all along. Can anyone tell me to help understand how this is usually done?

Many thanks for your help!

+3


source to share


1 answer


Check out Cron jobs for scheduling on Unix-like machines. Any decent web host will offer some sort of cron support.

The guide can be found here .



Example for the Monday

morning at the 0800

hour.

* 8 * * 1 php /path/to/my/script.php

      

+1


source







All Articles