Video_Import::__construct( string $resource_type, bool|string $resource_id = false, bool|string $user_id = false, array $args = array() )

Video_Import constructor.


Parameters

$resource_type

(string) (Required) The type of resource being queried (album, channel, search, etc.).

$resource_id

(bool|string) (Optional) The resource ID that should be retrieved from Vimeo API.

Default value: false

$user_id

(bool|string) (Optional) The user ID (if required) that owns the resource or false in case the parameter is not needed.

Default value: false

$args

(array) (Optional) Additional request parameters.

  • 'page'
    (int) The page number to retrieve from Vimeo API.
  • 'per_page'
    (int) Number of results per page.
  • 'query'
    (string) A search query to search within the set of results for further filtering.
  • 'filter'
    (string) Results filtering; has specific value based on the required feed type (ie. playable, embeddable, featured, live, etc.). See Vimeo API docs for the spcific resource imported to get the available filtering options.
  • 'filter_embeddable'
    (bool) Filter results by embeddable videos (true) or non-embeddable videos (false). Requires parameter "filter" to be set to "embeddable".
  • 'filter_playable'
    (bool) Whether to filter the results by playable videos (true) or non-playable videos (false).
  • 'links'
    (string) The page containing the video URI.
  • 'password'
    (string) Password for password restricted resources (ie. showcases).

Default value: array()


Source

File: includes/libs/video-import.class.php

	public function __construct( $resource_type, $resource_id = false, $user_id = false, $args = [] ){

		$this->api = new Vimeo_Api_Query( $resource_type, $resource_id, $user_id, $args );
		$request = $this->api->request_feed();
		// stop on error
		if( is_wp_error( $request ) ){
			$this->errors = $request;
			return;
		}
		
		$result = json_decode( $request['body'], true );
		
		/* single video entry */
		if( $this->api->get_api_resource()->is_single_entry() ){
			$this->results = $this->api->get_api_resource()->get_formatted_entry( $result );
			return;
		}

		$raw_entries = isset( $result['data'] ) ? $result['data'] : [];
		$entries =	[];
		foreach ( $raw_entries as $entry ){
			$_entry = $this->api->get_api_resource()
			                    ->get_formatted_entry( $entry );

			if( !is_null( $_entry ) ) {
				$entries[] = $_entry;
			}
		}		
		
		$this->results = $entries;
		$this->end = ( !isset( $result['paging']['next'] ) || empty( $result['paging']['next'] ) );
		$this->total_items = isset( $result['total'] ) ? $result['total'] : 0;
		$this->page = isset( $result['page'] ) ? $result['page'] : 0;
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!