rveitch
1/29/2016 - 8:26 PM

JW API: Query by Custom Properties Meta

JW API: Query by Custom Properties Meta

<?php
/**
 * JW API: Query by Custom Properties Meta
 *
 * Returns "videos/list" query results object based on custom properities (meta).
 * Allows for building relationships between videos and/or posts via meta keys.
 *
 * This example will return the three video segments for the 1/23/16 podcast.
 */
function fcc_jw_search( $string, $field ) {
  $botr_api = new BotrAPI( get_option('options_jw_platform_api_key'), get_option('options_jw_platform_api_secret') ); // Instantiate the API.
	$response = $botr_api->call("/videos/list", array( "search:{$field}" => $string ));
	return $response;
}

$field = 'custom.episode'; // "Episode" custom properties field
$string = '012316'; // Episode Date. Each episode has 3 segments.
printf("<pre>%s</pre>", json_encode( fcc_jw_search( $string, $field ),JSON_PRETTY_PRINT) );