Ejemplo n.º 1
0
 private function _fetch_fireeagle_positions($fireeagle_access_key, $fireeagle_access_secret)
 {
     $position = array();
     require_once MIDCOM_ROOT . '/external/fireeagle.php';
     $fireeagle = new FireEagle($this->_config->get('fireeagle_consumer_key'), $this->_config->get('fireeagle_consumer_secret'), $fireeagle_access_key, $fireeagle_access_secret);
     // Note: this must be C so we get floats correctly from JSON. See http://bugs.php.net/bug.php?id=41403
     setlocale(LC_NUMERIC, 'C');
     $user_data = $fireeagle->user();
     if (!$user_data || !$user_data->user || empty($user_data->user->location_hierarchy)) {
         return $position;
     }
     $best_position = $user_data->user->location_hierarchy[0];
     switch ($best_position->level_name) {
         case 'exact':
             $position['accuracy'] = 10;
             break;
         case 'postal':
             $position['accuracy'] = 20;
             break;
         case 'city':
             $position['accuracy'] = 30;
             break;
         default:
             $position['accuracy'] = 60;
             break;
     }
     $position['latitude'] = $best_position->latitude;
     $position['longitude'] = $best_position->longitude;
     $position['date'] = strtotime($best_position->located_at);
     return $position;
 }
Ejemplo n.º 2
0
function wpfe_display_best_guess_name()
{
    global $fe_key;
    global $fe_secret;
    $best_guess_name = wp_cache_get('wpfe_best_guess_name');
    if ($best_guess_name == false) {
        $access_token = get_option('wpfe_access_token');
        $access_secret = get_option('wpfe_access_secret');
        $fe = new FireEagle($fe_key, $fe_secret, $access_token, $access_secret);
        $loc = $fe->user();
        $best_guess_name = htmlspecialchars($loc->user->best_guess->name);
        if (empty($loc->user->location_hierarchy)) {
            ?>
Fire Eagle doesn't know where you are yet.<?php 
        }
        wp_cache_set('wpfe_best_guess_name', $best_guess_name);
    }
    echo $best_guess_name;
}