Q:

Ping the API Server for the changes in PHP

I am importing the products from a third party website, I'm using their web services to import the products. Now what is the best way to check for the API changes and products updates automatically and if changed or new products exists then load them.
Can i use ajax to ping the server after a specific amount of time or any other alternative way to achieve this ?

A:

Javascript handle timer nicely and reliabily. Only major drawback is that you need to keep the page opens all the time in your browser. Here is a jquery example of a repeated task calling an ajax (jquery is only used to provide a quick ajax, setInterval() function is native javascript)
var timerhandler;

$(document).ready(function() {

    function CheckNow()
    {

        $.ajax(
        {
            type: 'GET',
            url: '<your local php script calling the remote API>',
            success: function(data) 
            {
                //print out here the result of your script work
            }
        });

    }

    timerhandler = setInterval(CheckNow,50000);
    //50000 = 50 seconds
});

This is good for test but not good for production server. For production you should use scheduled task provided by the host OS. On linux-based : a cron task running wget with your php script as target.

