Code:
//////////////////////////////////////////////
/// Connect to APIs
//////////////////////////////////////////////
writeln("Testing connection to API...");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.bherbert.org/1.1/hello-world?time=" . time() . "&installer=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$data = curl_exec($ch);
if(strpos($data, "I come in peace.") === false) { exit("<h3>Uh oh!</h3> It seems the API server is down right now. The installer requires it. Please wait 5 minutes and try again."); }
writeln("... Connection established." . PHP_EOL);
writeln("Sending initial information to API server...");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.bherbert.org/1.1/alerts?for=seo-studio-2&url=".urlencode("N/A")."&version=".urlencode($version)."&absoluteUrl=" . urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]") . "&appId=" . urlencode($applicationId) . "&installer=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$data = curl_exec($ch);
if(strpos($data, "COMMUNICATIONS#1.1") === false) { exit("<h3>Uh oh!</h3> It seems the API server is down right now. The installer requires it. Please wait 5 minutes and try again."); }
writeln("... Information sent." . PHP_EOL);