PHP code example of byteark / byteark-sdk-php
1. Go to this page and download the library: Download byteark/byteark-sdk-php 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/ */
byteark / byteark-sdk-php example snippets
$signer = new \ByteArk\Signer\ByteArkV2UrlSigner([
'access_id' => '2Aj6Wkge4hi1ZYLp0DBG',
'access_secret' => '31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7',
]);
$signedUrl = $signer->sign(
'https://example.cdn.byteark.com/path/to/file.png',
1514764800,
[
'method' => 'GET',
]
);
/*
Output:
https://example.cdn.byteark.com/path/to/file.png
?x_ark_access_id=2Aj6Wkge4hi1ZYLp0DBG
&x_ark_auth_type=ark-v2
&x_ark_expires=1514764800
&x_ark_signature=OsBgZpn9LTAJowa0UUhlYQ
*/
$signer = new \ByteArk\Signer\ByteArkV2UrlSigner([
'access_id' => '2Aj6Wkge4hi1ZYLp0DBG',
'access_secret' => '31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7',
]);
$signedUrl = $signer->sign(
'https://example.cdn.byteark.com/live/playlist.m3u8',
1514764800,
[
'method' => 'GET',
'path_prefix' => '/live/',
]
);
echo $signedUrl;
/*
Output:
https://example.cdn.byteark.com/live/playlist.m3u8
?x_ark_access_id=2Aj6Wkge4hi1ZYLp0DBG
&x_ark_auth_type=ark-v2
&x_ark_expires=1514764800
&x_ark_path_prefix=%2Flive%2F
&x_ark_signature=7JGsff2mBQEOoSYHTjxiVQ
*/
$requestInfo = new \ByteArk\Request\RequestInfo();
$signer = new \ByteArk\Signer\ByteArkV2UrlSigner([
'access_id' => '2Aj6Wkge4hi1ZYLp0DBG',
'access_secret' => '31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7',
]);
$signedUrl = $signer->sign(
'http://inox.qoder.byteark.com/video-objects/QDuxJm02TYqJ/playlist.m3u8',
1514764800,
[
'method' => 'GET',
'path_prefix' => '/video-objects/QDuxJm02TYqJ/',
'referer' => $requestInfo->getCurrentUrl()
]
);