I’m writing a RESTlet which is submitted through a website via PHP. Before submitting, I need to check the webservice is responsive. I could make a curl request to the endpoint (see below) or perhaps create a dummy RESTlet which returns a set value. Since RESTlets can be slow, this perhaps is not the best route. How would you do it?
$url = 'https://123456459.restlets.api.netsuite.com/app/site/hosting/restlet.nl';
$cl = curl_init($url);
curl_setopt($cl,CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($cl,CURLOPT_HEADER,true);
curl_setopt($cl,CURLOPT_NOBODY,true);
curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cl,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($cl);
curl_close($cl);
if($response)
return 1;
else
return 0;