Created
July 19, 2010 02:53
-
-
Save solon/480961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Display a sensor value on a webpage | |
* Uses the Pachube PHP Library - download at http://community.pachube.com/tutorials/php | |
*/ | |
require_once('pachube_functions.php'); | |
// Obtain your API key here: http://www.pachube.com/users/my_username/settings | |
$api_key = 'YOUR_API_KEY'; | |
// replace this with the feed you are using | |
$feed_id = '8909'; | |
$url = 'http://www.pachube.com/api/'.$feed_id.'.csv'; | |
$pachube = new Pachube($api_key); | |
$environment = $pachube->environment( $feed_id ); | |
$data = $pachube->retrieveData ( $url ); | |
$sensor_readings = explode(",", $data); | |
//print_r ($sensor_readings); | |
?> | |
<html> | |
<head> | |
<title>My Sensors</title> | |
</head> | |
<body> | |
<table border="1" cellpadding="5"> | |
<tr> | |
<th>Sensor</th> | |
<th>Value</th> | |
</tr> | |
<tr> | |
<td>Light level</td> | |
<td><?php echo $sensor_readings[0]; ?></td> | |
</tr> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment