コード例 #1
0
    $password = $_GET['password'];
    $key = $_GET['key'];
}
// check authentication
if (!authenticate($email, $password, $key)) {
    deliver_response(401, "Unauthorized", NULL);
} else {
    //parse the query string
    parse_str($QUERY_STRING, $my_query);
    // if we have only email,password and key (3 query)
    if (count($my_query) == 3) {
        get_reading_type_list();
    } else {
        if (count($my_query) == 4 && isset($my_query['type'])) {
            //dispaly information about the mesh
            get_reading($my_query['type']);
        } else {
            if (count($my_query) == 5 && isset($my_query['type']) && isset($my_query['location'])) {
                //dispaly information about the mesh
                get_reading_by_location($my_query['type'], $my_query['location']);
            } else {
                if (count($my_query) == 6 && isset($my_query['type']) && isset($my_query['from']) && isset($my_query['to'])) {
                    //dispaly information about the mesh
                    get_reading_by_time($my_query['type'], $my_query['from'], $my_query['to']);
                } else {
                    // other type of request are bad request
                    deliver_response(400, "Bad Request", NULL);
                }
            }
        }
    }
コード例 #2
0
/**
 * Given an array of site information, returns the current values
 * 
 * @param array $site Associative array containing source feed and tags required
 * @return Associative array of value to be used
 */
function get_site_data($site)
{
    $querytype = isset($site['tagformat']) ? $site['tagformat'] : 'tags';
    // get readings from XML feed
    $reading = get_reading($site['source'], $site['tags'], $querytype);
    // convert reading format if required
    convert_reading($reading, $site['format']);
    // build output array
    $sitedata['name'] = $site['name'];
    $sitedata['reading'] = $reading;
    $sitedata['link'] = $site['link'];
    $sitedata['comment'] = $site['comment'];
    $sitedata['latitude'] = $site['latitude'];
    $sitedata['longitude'] = $site['longitude'];
    $sitedata['elevation'] = $site['elevation'];
    return $sitedata;
}