<?php midcom::get()->finish(); _midcom_stop_request(); } elseif (isset($_GET['f']) && $_GET['f'] == 'callback') { // the user has authorized us at FE, so now we can pick up our access token + secret if (!$session->exists('auth_state') || $session->get('auth_state') != 'start') { throw new midcom_error("Out of sequence."); } $fireeagle = new FireEagle($fireeagle_consumer_key, $fireeagle_consumer_secret, $session->get('request_token'), $session->get('request_secret')); $access_token = $fireeagle->getAccessToken(); if (!isset($access_token['oauth_token']) || !is_string($access_token['oauth_token']) || !isset($access_token['oauth_token_secret']) || !is_string($access_token['oauth_token_secret'])) { throw new midcom_error("Failed to get FireEagle access token\n"); } $user->set_parameter('net.yahoo.fireeagle', 'access_key', $access_token['oauth_token']); $user->set_parameter('net.yahoo.fireeagle', 'access_secret', $access_token['oauth_token_secret']); midcom::get()->relocate($_SERVER['SCRIPT_NAME']); // This will exit } ?> <p><a href="?f=start">Start Fire Eagle authentication</a></p> <?php midcom::get()->finish(); _midcom_stop_request(); } $fireeagle = org_routamc_positioning_importer::create('fireeagle'); $coordinates = $fireeagle->get_fireeagle_location($user); if ($coordinates) { echo sprintf('According to Fire Eagle your position since %s is %s', strftime('%x %X', $coordinates['date']), org_routamc_positioning_utils::microformat_location($coordinates['latitude'], $coordinates['longitude'])); } else { echo "Failed to get position, last error is {$fireeagle->error} {$fireeagle->error_string}"; }
<?php midcom::get('auth')->require_valid_user(); $user = midcom::get('auth')->user->get_storage(); $html = org_routamc_positioning_importer::create('html'); $coordinates = $html->get_icbm_location($user); if ($coordinates) { echo sprintf('According to ICBM URL your position is %s', org_routamc_positioning_utils::microformat_location($coordinates['latitude'], $coordinates['longitude'])); } else { echo "Failed to get position, last error is {$html->error}"; }