PHP code example of streamlike / php-api-sdk

1. Go to this page and download the library: Download streamlike/php-api-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/ */

    

streamlike / php-api-sdk example snippets




// via composer autoload
/src/Streamlike/Api/Sdk.php';



$login = 'myStreamlikeLogin';
$password = 'myStreamlikePassword';

$sdk = new \Streamlike\Api\Sdk();
try {
    $result = $sdk->authenticate($login, $password);

    $sessionToken = $result['token'];

    var_dump($sessionToken);
} catch (\Exception $e) {
    if ($e instanceof Streamlike\Api\Exception\InvalidInputException) {
        print_r($e->getErrors());
    }
}



$sdk = new \Streamlike\Api\Sdk($sessionToken);
try {
    $result = $sdk->call('medias');

    var_dump($result);
} catch (\Exception $e) {
    // handle errors
}




$sdk = new \Streamlike\Api\Sdk($sessionToken);
try {
    $data = [
        'name' => 'via sdk',
        'permalink' => 'via-sdk',
        'type' => 'video',
        'visibility' => [
            'state' => 'online',
        ],
    ];

    $files = [
        'source' => [
            'encode' => [
                'media_file' => '/path/to/video/file',
            ],
        ],
    ];

    $result = $sdk->call('medias', 'POST', $data, $files);
} catch (\Exception $e) {
    if ($e instanceof Streamlike\Api\Exception\InvalidInputException) {
        print_r($e->getErrors());
    }
}

git clone [email protected]:Streamlike/php-api-sdk.git streamlike-api
cd streamlike-api

php vendor/bin/atoum -d tests