示例#1
0
<?php

//This script retrieves the values from Cosm with the help of PachubeAPI and cosm_id_and_values_f.php.
//Former ist from https://github.com/cosm/cosm-js, the latter contains self-defined functions.
//functions from Cosm
include 'PachubeAPI.php';
//self-defined functions to get the values
include 'cosm_id_und_werte_f.php';
$pachube = new PachubeAPI("QgvMiPLj6wDkY3k2JSPpD3-rMAuSAKxLbVlLMVhxTURMOD0g");
//$alle contains all meta-information about all feeds with the tag 'munster' (ID,Title, see http://cosm.com/docs/v2/feed/list.html for further information) .
$alle = $pachube->getFeedsList("json", 0, 100000, "summary", "munster", "munster");
//array: contains all IDs with the tag 'munster'.
$ids = get_ids($alle);
//echo count($ids);
//array: contains the values for every ID in JSON format.
$json = get_json($ids);
//The following two arrays contain the coordinates. The values below are self-explaining.
$lat = get_lat($json);
$lon = get_lon($json);
$timestamp = get_timestamp($json);
$NO2 = get_NO2($json);
$CO = get_CO($json);
$O3 = get_O3($json);
$names = get_Name($json);
/*
for($i=0;$i<count($ids);$i++){
echo $ids[$i]."</br>";
echo $temperature[$i]."T"."</br>";
echo $humidity[$i]."H"."</br>";
}
for($i=0;$i<count($ids);$i++){
示例#2
0
<?php

include 'PachubeAPI.php';
$pachube = new PachubeAPI("YOUR_API_KEY");
$feed = FEED_ID;
$feed_to_delete = FEED_ID_TO_DELETE;
$user = "******";
echo "<h2>getFeedsList(): </h2><br/>";
echo "<code>" . $pachube->getFeedsList("json", 2, 1, "summary", "energy") . "</code><br/>";
echo "<h2>getFeed(): </h2><br/>";
echo "<code>" . $pachube->getFeed("csv", $feed) . "</code><br/>";
echo "<h2>updateFeed(): </h2><br/>";
$data = "0,10";
echo "<code>" . $pachube->_debugStatus($pachube->updateFeed("csv", $feed, $data)) . "</code><br/>";
echo "<h2>deleteFeed(): </h2><br/>";
echo "<code>" . $pachube->_debugStatus($pachube->deleteFeed($feed_to_delete)) . "</code><br/>";
echo "<h2>getDatastreamsList(): </h2><br/>";
echo "<code>" . print_r($pachube->getDatastreamsList($feed)) . "</code><br/>";
echo "<h2>createDatastream(): </h2><br/>";
$data = "energy,19";
echo "<code>" . $pachube->_debugStatus($pachube->createDatastream("csv", $feed, $data)) . "</code><br/>";
echo "<h2>getDatastream(): </h2><br/>";
echo "<code>" . $pachube->getDatastream("json", $feed, 0) . "</code><br/>";
echo "<h2>updateDatastream(): </h2><br/>";
$data = "9";
echo "<code>" . $pachube->_debugStatus($pachube->updateDatastream("csv", $feed, 0, $data)) . "</code><br/>";
echo "<h2>deleteDatastream(): </h2><br/>";
echo "<code>" . $pachube->_debugStatus($pachube->deleteDatastream($feed, "energy")) . "</code><br/>";
echo "<h2>getUser(): </h2><br/>";
echo "<code>" . $pachube->getUser("xml", $user) . "</code><br/>";
echo "<h2>getFeedHistory(): </h2><br/>";