Zoom_Webinar_Helpers::api_get_user_info()

Returns the zoom user from transient or from zoom api.


Return Return

(mixed) The zoom user if tokens are available. Otherwise, false.


Source Source

File: src/integrations/zoom-webinar/helpers/zoom-webinar-helpers.php

	public function api_get_user_info() {

		$transient_key = 'uap_automator_zoom_webinar_api_user_info';

		$saved_user_info = get_transient( $transient_key );

		if ( false !== $saved_user_info ) {
			return $saved_user_info;
		}

		$client = $this->get_client();

		if ( ! $client || empty( $client['access_token'] ) ) {
			return false;
		}

		$response = wp_remote_post(
			$this->automator_api,
			array(
				'body' =>
					array(
						'action'       => 'get_user',
						'access_token' => $client['access_token'],
					),
			)
		);

		$status_code = wp_remote_retrieve_response_code( $response );

		if ( 200 === $status_code ) {
			$response_body = json_decode( wp_remote_retrieve_body( $response ) );
			set_transient( $transient_key, $response_body->data, WEEK_IN_SECONDS );
			return $response_body->data;
		}

		return false;

	}