Page_API::get_access_expiration( $access_token )

Get the video live stream permalink.


Parameters

$video_id

(int) (Required) The Facebook video id.


Top ↑

Return

(string) The expiration, either never or a timestamp.


Top ↑

Source

File: src/Tribe/Meetings/Facebook/Page_API.php

	public function get_access_expiration( $access_token ) {
		$expiration = '';

		$this->get(
			$this->get_access_expiration_url_with_query_strings( $access_token ),
			[]
	    )->then(
			function ( array $response ) use ( &$expiration ) {

				if (
				   ! (
				       isset( $response['body'] ) &&
				       false !== ( $body = json_decode( $response['body'], false ) )
				   )
				) {
				   do_action( 'tribe_log', 'error', __CLASS__, [
				       'action'   => __METHOD__,
				       'message'  => 'Facebook API response is missing the required information to get the video permalink.',
				       'response' => $body,
				   ] );

				   return false;
				}

				  if ( ! isset( $body->data->expires_at ) ) {
				      return false;
				  }

				  $expiration = $body->data->expires_at;

				  return true;
			}
		)->or_catch(
			function ( \WP_Error $error ) {
			  do_action( 'tribe_log', 'error', __CLASS__, [
			      'action'  => __METHOD__,
			      'code'    => $error->get_error_code(),
			      'message' => $error->get_error_message(),
			  ] );
			}
		);

		if( 0 === $expiration) {
			return 'never';
		}


		return $expiration;
	}

Top ↑

Changelog

Changelog
Version Description
1.7.0 Introduced.