The JWPlatform PHP library provides convenient access to the JW Platform Management API from applications written in the PHP language.
Visit JW Player Developer site for more information about JW Platform API.
PHP 5.6.0 and later.
You can install the bindings via Composer. Run the following command:
composer require jwplayer/jwplatformTo use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');If you do not wish to use Composer, you can download the
latest release.
Then, to use the bindings, include the init.php file.
require_once('/path/to/jwplatform-php/init.php');The bindings require the following extensions in order to work properly:
curl, although you can use your own non-cURL client if you prefer
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Example of getting video metadata:
$jwplatform_api = new Jwplayer\JwplatformAPI('INSERT API KEY', 'INSERT API SECRET');
$video_key = 'INSERT VIDEO KEY';
$response = $jwplatform_api->call('/videos/show', array('video_key'=>$video_key));Example of uploading a file:
$jwplatform_api = new Jwplayer\JwplatformAPI('INSERT API KEY', 'INSERT API SECRET');
$target_file = 'examples/test.mp4';
$params = array();
$params['title'] = 'PHP API Test Upload';
$params['description'] = 'Video description here';
// Create video metadata
$create_response = json_encode($jwplatform_api->call('/videos/create', $params));
$decoded = json_decode(trim($create_response), TRUE);
$upload_link = $decoded['link'];
$upload_response = $jwplatform_api->upload($upload_link, $target_file);
print_r($upload_response);Get Composer. For example, on Mac OS:
brew install composerInstall dependencies:
composer installJW Platform API library is distributed under the MIT license.