'upload videos file with jwplatform [PHP]

so here is my problem:

I want to use jwplatform-php to upload my video files.

here is my php script: (this is more or less the sample script provided)

<?php

use Jwplayer\JwplatformClient;

header_remove( 'X-Powered-By' );
chdir(dirname(__DIR__));


require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';


$secret = "XXXXXXXXXXXXXXXXXXX";
$site_id = "XXXXX";

$jwplatform_api = new JwplatformClient($secret);

$target_file = "test.mp4";

$params = [];
$params['metadata'] = [];
$params['metadata']['title'] = 'PHP API Test Upload';
$params['metadata']['description'] = 'Video description here';
$params['upload'] = [];
$params['upload']['method'] = 'direct';

// Create the example media
$create_response = json_encode($jwplatform_api->Media->create($site_id, $params));

print_r($create_response);
print("\n");


$decoded = json_decode(json_decode(trim($create_response), true), true);

$upload_link = $decoded['upload_link'];

// Upload the media file
$upload_response = $jwplatform_api->Media->upload($target_file, $upload_link);

print_r($upload_response);
print("\n");

And so the error occurs at $create_response he return false.

I think the problem is $target_file = "test.mp4"; that he can't solve even by putting the relative path $target_file = dirname(__FILE__) . DIRECTORY_SEPARATOR ."test.mp4"; he returns to me false.

I don't know what to do and in addition the doc jwplatform-php is almost non-existent

I thank you already for all the help provided and sorry for my approximate English...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source