public static function OAuthLogin($auth_tokens, $get_token = 'getAccessToken', $save_token = 'saveAccessToken', $delete_token = 'deleteAccessToken') { $user = false; $response = array(); # Attempt to authenticate this user using an access_token, if available if (!isset($auth_tokens['access_token'])) { if (is_callable($get_token)) { $auth_tokens['access_token'] = $get_token(); } elseif (is_callable(array('self', $get_token))) { $auth_tokens['access_token'] = self::$get_token(); } } if (isset($auth_tokens['access_token'])) { try { // Example using an access_token to initialize the API client: $eb = new Eventbrite(array('access_token' => $auth_tokens['access_token'])); $user = $eb->user_get()->user; } catch (Exception $e) { $user = false; // This token may no longer be valid // refresh it, or clear it $response['login_error'] = $e->getMessage(); if (is_callable($delete_token)) { $delete_token($auth_tokens['access_token']); } elseif (is_callable(array('self', $delete_token))) { self::$delete_token($auth_tokens['access_token']); } } } # We do not have a valid access token for this user so far if ($user == false) { # This user is not yet authenticated - # it is their first visit, # or they are returning with an access_code that we will exchange for an access_token, # or they were redirected here after logout if (isset($auth_tokens['access_code'])) { # This user has just authenticated, get their access token and store it try { $eb = new Eventbrite($auth_tokens); $response['access_token'] = $eb->auth_tokens['access_token']; // save this access_token for future use! if (is_callable($save_token)) { $save_token($response['access_token']); } elseif (is_callable(array('self', $save_token))) { self::$save_token($response['access_token']); } header('Location: ' . $_SERVER['PHP_SELF']); exit; } catch (Exception $e) { $response['login_error'] = $e->getMessage(); } } else { if (isset($auth_tokens['error_message'])) { if ($auth_tokens['error_message'] == 'access_denied') { $response['login_error'] = "Account access denied."; } else { $response['login_error'] = $auth_tokens['error_message']; } } } } else { if (is_object($user)) { $response['user_email'] = $user->email; $response['user_name'] = $user->first_name . ' ' . $user->last_name; } } return $response; }
$params['timezone'] = $_POST['timezone']; $params['before_period'] = $_POST['before_period']; $params['after_period'] = $_POST['after_period']; $config->setConfig($params); $config->write(); } // $config->read(); $app_key = $config->getParam('app_key'); $user_key = $config->getParam('user_key'); $output_file_name = $config->getParam('output_file_name'); $before_period = $config->getParam('before_period'); $after_period = $config->getParam('after_period'); // Get the user data ... $eb_client = new Eventbrite(array('app_key' => $app_key, 'user_key' => $user_key)); try { $user = $eb_client->user_get(); } catch (Exception $ex) { // No events means the key is no good // This is a validation that should be reported, but for now // we just clear the params ... $message = $ex->getMessage(); } ?> <!-- Use the .htaccess and remove these lines to avoid edge case issues. More info: h5bp.com/i/378 --> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta> <title>Eventbrite iCalendar Interface</title> <meta name="description" content=""></meta> <!-- Mobile viewport optimized: h5bp.com/viewport -->