Facebook_Helpers::automator_integration_facebook_capture_token()

Capture the user token and id.


Source Source

File: src/integrations/facebook/helpers/facebook-helpers.php

	public function automator_integration_facebook_capture_token() {

		$settings = array(
			'user' => array(
				'id'    => filter_input( INPUT_GET, 'fb_user_id', FILTER_SANITIZE_NUMBER_INT ),
				'token' => filter_input( INPUT_GET, 'fb_user_token', FILTER_SANITIZE_STRING ),
			),
		);

		$error_status = filter_input( INPUT_GET, 'status', FILTER_DEFAULT );

		if ( 'error' === $error_status ) {
			wp_safe_redirect( $this->get_settings_page_uri() . '&status=error' );
			exit;
		}

		// Only update the record when there is a valid user.
		if ( isset( $settings['user']['id'] ) && isset( $settings['user']['token'] ) ) {
			// Updates the option value to settings.
			update_option( self::OPTION_KEY, $settings );
			// Delete any settings left.
			delete_option( '_uncannyowl_facebook_pages_settings' );
		}

		wp_safe_redirect( $this->get_settings_page_uri() );

		exit;

	}