stardots-io/stardots-sdk-php

PHP SDK for StarDots platform

dev-main 2025-06-26 07:43 UTC

This package is auto-updated.

Last update: 2025-06-26 14:55:37 UTC


README

logo.png

StarDots-SDK-PHP

PHP CodeQL codecov LICENSE: MIT

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

  1. Download the source code
  2. Include the autoloader or manually include the files
  3. 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

Homepage

https://stardots.io