Instructables

Ski Resort Desk Snow Meter (Snowbird)

Step 5: Bonus Feature: Twilio

Picture of Bonus Feature: Twilio
PHP Script with Twilio output:
----------------------------------------------------------------------------------------------------------------
<?php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "http://www.snowbird.com/index.html");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);

$output = trim($output);
$twentyfour = explode('24hr:<b><font color="FBE075">',$output);
$twentyfour = explode('</font></b>',$twentyfour[1]);

$fortyeight = explode('48hr:<b><font color="FBE075">', $output);
$fortyeight = explode('</font></b>',$fortyeight[1]);

$ytd = explode('YTD:<b><font color="FBE075">', $output);
$ytd = explode('</font></b>',$ytd[1]);

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<Response><Say>Snowbird Resort had " . $twentyfour[0] . " inches in the last twenty four hours, " . $fortyeight[0] . " inches in the last forty eight hours, and " .$ytd[0]. " inches year to date.</Say></Response>";
?>             
----------------------------------------------------------------------------------------------------------------
 
Remove these adsRemove these ads by Signing Up