static function Facebook_registration()
 {
     // Decode Facebook data
     $reg = WPAL2Int::Parse_signed_request($_REQUEST['user']);
     // Check result
     if ($reg == null) {
         header('Content-type: text/plain');
         _e('Facebook registration failed', c_al2fb_text_domain);
         echo PHP_EOL;
         if (get_option(c_al2fb_option_debug)) {
             print_r($_REQUEST);
         }
     } else {
         try {
             // Validate
             $url = 'https://graph.facebook.com/v2.2/' . $reg['user_id'];
             $url = apply_filters('al2fb_url', $url);
             $query = http_build_query(array('access_token' => $reg['oauth_token']), '', '&');
             $response = WPAL2Int::Request($url, $query, 'GET');
             $me = json_decode($response);
             $email = empty($me) ? null : $me->email;
             if (!get_option('users_can_register')) {
                 // Registration not enabled
                 header('Content-type: text/plain');
                 _e('User registration disabled', c_al2fb_text_domain);
                 echo PHP_EOL;
             } else {
                 if (empty($email)) {
                     // E-mail missing
                     header('Content-type: text/plain');
                     _e('Facebook e-mail address missing', c_al2fb_text_domain);
                     echo PHP_EOL;
                     if (get_option(c_al2fb_option_debug)) {
                         print_r($reg);
                         print_r($me);
                     }
                 } else {
                     $user_ID = false;
                     if (email_exists($email)) {
                         $user = get_user_by('email', $email);
                         if ($user) {
                             $user_ID = $user->ID;
                         } else {
                             header('Content-type: text/plain');
                             _e('User not found', c_al2fb_text_domain);
                             echo PHP_EOL;
                             echo $email;
                         }
                     } else {
                         // Create new WP user
                         $user_ID = wp_insert_user(array('first_name' => $reg['registration']['first_name'], 'last_name' => $reg['registration']['last_name'], 'user_email' => $email, 'user_login' => $reg['registration']['user_name'], 'user_pass' => $reg['registration']['password']));
                         // Check result
                         if (is_wp_error($user_ID)) {
                             header('Content-type: text/plain');
                             _e($user_ID->get_error_message());
                             echo PHP_EOL;
                             if (get_option(c_al2fb_option_debug)) {
                                 print_r($reg);
                             }
                             $user_ID = false;
                         }
                     }
                     // Redirect
                     if ($user_ID) {
                         update_user_meta($user_ID, c_al2fb_meta_facebook_id, $me->id);
                         $url = get_user_meta($user_ID, c_al2fb_meta_reg_success, true);
                         if (empty($url)) {
                             $url = get_home_url();
                         }
                         wp_redirect($url);
                     }
                 }
             }
         } catch (Exception $e) {
             // Communication error?
             header('Content-type: text/plain');
             _e('Could not verify Facebook registration', c_al2fb_text_domain);
             echo PHP_EOL;
             echo $e->getMessage();
             if (get_option(c_al2fb_option_debug)) {
                 print_r($_REQUEST);
                 print_r($response);
             }
         }
     }
 }