PHP code example of safestream / safestream-php-sdk
1. Go to this page and download the library: Download safestream/safestream-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
safestream / safestream-php-sdk example snippets
$safeStreamClient = new \SafeStream\SafeStreamClient(["apiKey" => "YOUR API KEY", "clientId" => "YOUR CLIENT ID"]);
$safeStreamClient = new \SafeStream\SafeStreamClient(["apiKey" => "YOUR API KEY", "clientId" => "YOUR CLIENT ID", "domainId" => "YOUR DOMAIN ID"]);
$safeStreamClient.video().createFromSourceUrl("https://example.com/my-video.mp4");
$safeStreamClient.video().create(["sourceUrl" => "https://example.com/my-video.mp4", "key" => "red-carpet-reel-20"]);
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "YOUR NAME"]);
$safeStreamClient->watermark()->create("YOUR VIDEO KEY", $watermarkConfiguration, 90000);
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "YOUR NAME"]);
$safeStreamClient->watermark()->createFromTemplate("YOUR VIDEO KEY", "TEMPLATE ID", array("first_name", "Joe"));
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration();
$watermarkConfiguration
.withContent("YOUR NAME")
.withX(0.0)
.withY(0.0)
.move(1, 0, 0, 20);
$safeStreamClient->watermark()->create("YOUR VIDEO KEY", $watermarkConfiguration, 90000);
$watermarkConfiguration = new \SafeStream\Watermark\WatermarkConfiguration(["content" => "[%first_name%]"]);
$template = new \SafeStream\Watermark\Template\Template();
$template->addWatermarkConfiguration($watermarkConfiguration);
$safeStreamClient->watermark()->template()->save($template);
$watermarkClient->watermark()->createFromTemplate("YOUR VIDEO KEY", "YOUR TEMPLATE ID", array("first_name" => "Joe"));
// Require autoload which is installed via composer
ser can not modify them client side
$name = "Sample User";
$email = "[email protected] ";
$company = "Acme Studios 22";
// Instantiate the SafeStreamClient using your own API Key
$safeStreamClient = new \SafeStream\SafeStreamClient(["protocol" => "https", "hostName" => "api.safestream.com", "apiKey" => "XXXX"]);
// Configuration for the Name
$watermarkConfiguration1 = new \SafeStream\Watermark\WatermarkConfiguration([
"content" => "Licensed to " . $name,
"fontColor" => "FFFFFF",
"y" => 0.83,
"x" => 0.03,
"fontOpacity" => 0.5,
"fontSize" => 0.03,
"horizontalAlignment" => "LEFT",
"verticalAlignment" => "TOP"
]);
// Configuration for the Company
$watermarkConfiguration2 = new \SafeStream\Watermark\WatermarkConfiguration([
"content" => $company,
"fontColor" => "FFFFFF",
"y" => 0.04,
"x" => 0.97,
"fontOpacity" => 0.5,
"fontSize" => 0.03,
"horizontalAlignment" => "RIGHT",
"verticalAlignment" => "TOP",
"shadowColor" => "000000",
"shadowOffsetX" => 0.08,
"shadowOffsetY" => 0.08,
"shadowOpacity" => 0.33
]);
$mydata = $safeStreamClient -> watermark()->create("feature-1",array($watermarkConfiguration1,$watermarkConfiguration2),0);
// Return the request to the browser
echo json_encode($mydata);
}
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
composer.phar
export SAFESTREAM_CLIENT_ID=YOUR_CLIENT_ID
export SAFESTREAM_API_KEY=YOUR_API_KEY
phpunit tests/SafeStreamClientTests.php