PHP code example of sbrimon / streamtape-php-client

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

    

sbrimon / streamtape-php-client example snippets




// Include the Streamtape class
tape login and API key
//login= API-Login
//key= API-Key / API-Password
$streamtape = new Streamtape('your_login', 'your_api_key');

// Get account information
$AccountInfo = $streamtape->AccountInfo()->toArray();
echo "Email: " . $AccountInfo['email'] . "\n";

// File to upload (using $_FILES array)
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $file = $_FILES['file']; // Ensure 'file' is from an HTML form
   
    $upload = $streamtape->Upload($file,'my video title.mp4','folderid'); //video name and folder id are optional.
    ///json return
    echo "Upload Response: " . $upload->json();
    //or
    //Array Return
    print_r($upload->toArray());
}


// Add a remote upload from a URL
$streamtape->RemoteUpload('https://example.com/myfile.mp4');
echo "Remote Upload Response: " . $streamtape->json();

// Remove a specific remote upload
$streamtape->RemoveRemoteUpload('remote_upload_id');
echo "Remote Upload Removal: " . $streamtape->json();

// Check remote upload status
$streamtape->RemoteUploadStatus('remote_upload_id');
echo "Remote Upload Status: " . $streamtape->json();

// Get file information
$fileInfo = $streamtape->FileInfo('file_id');
echo "File Info: " . $fileInfo->json();//json data return
echo "File Info: " . print_r($fileInfo->toArray());//array data return

// List files in a folder
$files = $streamtape->ListFiles('folder_id');
echo "Files: " . $files->json();

// Create a new folder
$streamtape->NewFolder('new_folder_name');
echo "Folder Creation Response: " . $streamtape->json();

// Rename a folder
$streamtape->RenameFolder('folder_id', 'new_folder_name');
echo "Folder Rename Response: " . $streamtape->json();

// Delete a folder
$streamtape->DeleteFolder('folder_id');
echo "Folder Deletion Response: " . $streamtape->json();

// Rename a file
$streamtape->RenameFile('file_id', 'new_file_name');
echo "File Rename Response: " . $streamtape->json();

// Move a file to a folder
$streamtape->MoveFile('file_id', 'folder_id');
echo "File Move Response: " . $streamtape->json();

// Delete a file
$streamtape->DeleteFile('file_id');
echo "File Deletion Response: " . $streamtape->json();

// Get running conversions
$streamtape->RunningConverts();
echo "Running Conversions: " . $streamtape->json();

// Get failed conversions
$streamtape->FailedConverts();
echo "Failed Conversions: " . $streamtape->json();

// Get thumbnail image for a file
$streamtape->Thumbnail('file_id');
echo "Thumbnail: " . $streamtape->json(); //$streamtape->toArray();
bash
composer