Example #1
0
function oauth_callback($config)
{
    $o = new SaeTOAuthV2($config['appid'], $config['appkey']);
    if (isset($_REQUEST['code'])) {
        $keys = array();
        $keys['code'] = $_REQUEST['code'];
        $keys['redirect_uri'] = get_callback_url();
        try {
            $token = $o->getAccessToken('code', $keys);
        } catch (OAuthException $e) {
        }
    }
    if ($token) {
        $session = new session();
        $session->set('oauth_data', array('token' => $token, 'oauth_openid' => $token['access_token']));
    }
}
function verify_facebook_callback()
{
    $app_properties = facebook_client()->api_client->admin_getAppProperties(array('callback_url'));
    $facebook_callback_url = idx($app_properties, 'callback_url');
    $local_callback_url = get_callback_url();
    if (!$facebook_callback_url) {
        throw new Exception('You need to configure your callback URL in the ' . '<a href="http://www.facebook.com/developers/">Facebook Developers App</a>');
    }
    if (!$local_callback_url) {
        throw new Exception('Copy your Facebook callback URL into lib/config.php. ' . 'Your Callback is ' . $facebook_callback_url);
    }
    if (strpos($local_callback_url, 'http://') === null) {
        throw new Exception('Your configured callback url must begin with http://. ' . 'It is currently set to "' . $local_callback_url . '"');
    }
    if (get_domain($facebook_callback_url) != get_domain($local_callback_url)) {
        throw new Exception('Your config file says the callback URL is "' . $local_callback_url . '", but Facebook says "' . $facebook_callback_url . '"');
    }
    if (get_domain($local_callback_url) != get_domain($_SERVER['SCRIPT_URI'])) {
        throw new Exception('Your config file says the callback URL is "' . $local_callback_url . '", but you are on "' . $_SERVER['SCRIPT_URI'] . '"');
    }
}
Example #3
0
function is_config_setup()
{
    return get_api_key() && get_api_secret() && get_api_key() != 'YOUR_API_KEY' && get_api_secret() != 'YOUR_API_SECRET' && get_callback_url() != null;
}
Example #4
0
function ensure_loaded_on_correct_url()
{
    $current_url = get_current_url();
    $callback_url = get_callback_url();
    if (!$callback_url) {
        $error = 'You need to specify $callback_url in lib/config.php';
    }
    if (!$current_url) {
        error_log("therunaround: Unable to figure out what server the " . "user is currently on, skipping check ...");
        return;
    }
    if (get_domain($callback_url) != get_domain($current_url)) {
        // do a redirect
        $url = 'http://' . get_domain($callback_url) . $_SERVER['REQUEST_URI'];
        $error = 'You need to access your website on the same url as your callback. ' . 'Accessed at ' . get_domain($current_url) . ' instead of ' . get_domain($callback_url) . '. Redirecting to <a href="' . $url . '">' . $url . '</a>...';
        $redirect = '<META HTTP-EQUIV=Refresh CONTENT="10; URL=' . $url . '">';
    }
    if (isset($error)) {
        echo '<head>' . '<title>The Run Around</title>' . '<link type="text/css" rel="stylesheet" href="style.css" />' . isset($redirect) ? $redirect : '' . '</head>';
        echo render_error($error);
        exit;
    }
}