stardots-io / stardots-sdk-php
PHP SDK for StarDots platform
dev-main
2025-06-26 07:43 UTC
Requires
- php: >=5.5.0
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpmd/phpmd: ^2.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^5.0|^6.0|^7.0|^8.0|^9.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-06-26 14:55:37 UTC
README
StarDots-SDK-PHP
Introduction
This project is used to help developers quickly access the StarDots platform and is written in PHP. Compatible with PHP 5.5+.
Requirements
PHP version >= 5.5.0
cURL extension
JSON extension
Installation
Using Composer (Recommended)
composer require stardots-io/stardots-sdk-php
Manual Installation
- Download the source code
- Include the autoloader or manually include the files
- Use the SDK
Usage
Basic Example
<?php require_once 'vendor/autoload.php'; use StarDots\StarDots; // Initialize the SDK $clientKey = "Your client key"; $clientSecret = "Your client secret"; $stardots = new StarDots($clientKey, $clientSecret); // Or use the static create method $stardots = StarDots::create($clientKey, $clientSecret); // Get space list $params = [ 'page' => 1, 'pageSize' => 20 ]; $response = $stardots->getSpaceList($params);
API Examples
Get Space List
$params = [ 'page' => 1, 'pageSize' => 50 ]; $response = $stardots->getSpaceList($params);
Create Space
$params = [ 'space' => 'demo', 'public' => true ]; $response = $stardots->createSpace($params);
Delete Space
$params = [ 'space' => 'demo' ]; $response = $stardots->deleteSpace($params);
Toggle Space Accessibility
$params = [ 'space' => 'demo', 'public' => false ]; $response = $stardots->toggleSpaceAccessibility($params);
Get Space File List
$params = [ 'page' => 1, 'pageSize' => 50, 'space' => 'demo' ]; $response = $stardots->getSpaceFileList($params);
Get File Access Ticket
$params = [ 'space' => 'demo', 'filename' => 'example.png' ]; $response = $stardots->fileAccessTicket($params);
Upload File
$fileContent = file_get_contents('path/to/file.png'); $params = [ 'space' => 'demo', 'filename' => 'example.png', 'fileContent' => $fileContent ]; $response = $stardots->uploadFile($params);
Delete File
$params = [ 'space' => 'demo', 'filenameList' => ['example.png', 'example2.jpg'] ]; $response = $stardots->deleteFile($params);
Error Handling
try { $response = $stardots->getSpaceList(); } catch (StarDots\StarDotsException $e) { echo "Error: " . $e->getMessage(); }
Response Format
All API responses follow this format:
[ 'code' => 200, 'message' => 'Success', 'requestId' => 'unique-request-id', 'bool' => true, 'ts' => 1640995200000, 'data' => [ // Response data ] ]
Documentation
https://stardots.io/en/documentation/openapi