A simple PHP client for interacting with the Streamtape API. This client allows you to manage files, retrieve account information, and perform other operations easily via an object-oriented interface.
- Retrieve Account Information
- Upload
- Remote Upload
- Remove Remote Upload
- Check Remote Upload Status
- File Info
- List Folder/Files
- Create Folder
- Rename Folder
- Delete Folder
- Rename File
- Move File
- Delete File
- Lists Running Conversions
- Lists Failed Conversions
- Get Thumbnail Image
You can install this library either by using Composer or by manually downloading the files.
If you are using Composer, you can add this repository to your composer.json
:
composer require sbrimon/streamtape-php-client
If you prefer to manually install, download the Streamtape.php
file and include it in your project like this:
require_once 'path/to/Streamtape.php';
To use the client, you need to initialize the Streamtape
class with your Streamtape credentials: your login and API key.
// Include the Streamtape class
require_once 'path/to/Streamtape.php';
// Initialize with your Streamtape login and API key
//login= API-Login
//key= API-Key / API-Password
$streamtape = new Streamtape('your_login', 'your_api_key');
You can retrieve your account information (such as email) by calling the AccountInfo()
method.
// Get account information
$AccountInfo = $streamtape->AccountInfo()->toArray();
echo "Email: " . $AccountInfo['email'] . "\n";
To upload a file, use the Upload()
method. You can pass a file, and optionally specify the folder, file name, and SHA256 hash.
// 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());
}
To add a remote upload, use the RemoteUpload()
method by providing a remote URL and optional parameters like folder, custom name, and headers.
// Add a remote upload from a URL
$streamtape->RemoteUpload('https://example.com/myfile.mp4');
echo "Remote Upload Response: " . $streamtape->json();
To remove a remote upload (or all), call the RemoveRemoteUpload()
method and pass the remote upload ID or 'all' to delete all.
// Remove a specific remote upload
$streamtape->RemoveRemoteUpload('remote_upload_id');
echo "Remote Upload Removal: " . $streamtape->json();
To check the status of a remote upload, use the RemoteUploadStatus()
method by providing the remote upload ID.
// Check remote upload status
$streamtape->RemoteUploadStatus('remote_upload_id');
echo "Remote Upload Status: " . $streamtape->json();
To retrieve file information, use the FileInfo()
method with the file ID.
// 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
You can list files in a specific folder using the ListFiles()
method.
// List files in a folder
$files = $streamtape->ListFiles('folder_id');
echo "Files: " . $files->json();
To create a new folder, use the NewFolder()
method and specify the folder name (and optionally the parent folder ID).
// Create a new folder
$streamtape->NewFolder('new_folder_name');
echo "Folder Creation Response: " . $streamtape->json();
To rename an existing folder, use the RenameFolder()
method by providing the folder ID and the new folder name.
// Rename a folder
$streamtape->RenameFolder('folder_id', 'new_folder_name');
echo "Folder Rename Response: " . $streamtape->json();
To delete a folder, use the DeleteFolder()
method by providing the folder ID.
// Delete a folder
$streamtape->DeleteFolder('folder_id');
echo "Folder Deletion Response: " . $streamtape->json();
To rename a file, use the RenameFile()
method and provide the file ID and new file name.
// Rename a file
$streamtape->RenameFile('file_id', 'new_file_name');
echo "File Rename Response: " . $streamtape->json();
You can move a file to a different folder with the MoveFile()
method, by providing the file ID and the target folder ID.
// Move a file to a folder
$streamtape->MoveFile('file_id', 'folder_id');
echo "File Move Response: " . $streamtape->json();
To delete a file, use the DeleteFile()
method with the file ID.
// Delete a file
$streamtape->DeleteFile('file_id');
echo "File Deletion Response: " . $streamtape->json();
You can retrieve a list of running conversions using the RunningConverts()
method.
// Get running conversions
$streamtape->RunningConverts();
echo "Running Conversions: " . $streamtape->json();
To list all failed conversions, use the FailedConverts()
method.
// Get failed conversions
$streamtape->FailedConverts();
echo "Failed Conversions: " . $streamtape->json();
To retrieve a thumbnail image for a specific file, use the Thumbnail()
method and provide the file ID.
// Get thumbnail image for a file
$streamtape->Thumbnail('file_id');
echo "Thumbnail: " . $streamtape->json(); //$streamtape->toArray();
- those method return you json or array type data. you can use whichever you want to use
- Example
-
$streamtape->ListFiles()->toArray(); //this will return array data.
-
$streamtape->ListFiles()->json(); //this will return json data.
-
- Parameters: None
- Parameters:
$fileId
(required): The file ID to retrieve information for.
- Parameters:
$folder
(optional): Folder ID to list files from. If not provided, lists files from the root.
- Parameters:
$name
(required): The name of the new folder to be created.$pid
(optional): Parent folder ID (if creating inside another folder).
- Parameters:
$folder
(required): The folder ID to rename.$name
(required): The new name for the folder.
- Parameters:
$folder
(required): The folder ID to delete.
- Parameters:
$file
(required): The file ID to rename.$name
(required): The new name for the file.
- Parameters:
$file
(required): The file ID to move.$folder
(required): The folder ID to move the file to.
- Parameters:
$file
(required): The file ID to delete.
- Parameters: None
- Parameters: None
- Parameters:
$file
(required): The file ID to get the thumbnail for.
- Parameters:
$url
(required): The remote URL to upload.$folder
(optional): The folder ID to upload the file to.$name
(optional): A custom name for the uploaded file.$headers
(optional): Additional HTTP headers for the request.
- Parameters:
$id
(required): The remote upload ID to remove. Pass 'all' to remove all remote uploads.
- Parameters:
$id
(required): The remote upload ID to check the status of.
- Parameters:
$videoFile
(required): The file to upload (passed in a$_FILES
array).$fileName
(optional): The desired file name on Streamtape.$folder
(optional): The folder ID to upload the file to.$sha256
(optional): The SHA256 hash of the file to upload.$httponly
(optional): Whether or not to make the file available via HTTP only.
For additional API methods, refer to the Streamtape API documentation.
This project is licensed under the MIT License - see the LICENSE file for details.
- The installation section explains how to install via Composer or manually.
- The usage section covers initializing the client, getting account info, listing files, retrieving file info, and handling errors.
- The example usage section shows a real-world example.
- The methods section lists the available API methods you can use.
This README provides a complete and user-friendly guide for anyone who wants to use my PHP Streamtape client!