yourimageshare/yourimageshare-php

Official PHP SDK for the YourImageShare upload API (https://yourimageshare.com/about/api).

Maintainers

Package info

github.com/MediaShareORG/yourimageshare-php

Homepage

pkg:composer/yourimageshare/yourimageshare-php

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-08-27 13:23 UTC

This package is auto-updated.

Last update: 2026-08-27 13:52:19 UTC


README

Packagist version license

Official PHP SDK for the YourImageShare upload API. Zero Composer dependencies (uses PHP's own curl extension), PHP 7.4+.

Install

composer require yourimageshare/yourimageshare-php

Usage

use YourImageShare\YourImageShare;

$client = new YourImageShare('YOUR_API_KEY');

// Upload a file by path
$result = $client->upload('photo.jpg');
echo $result->direct; // https://yourimageshare.com/ib/aB3xY9qRz1

// Upload with auto-delete after 1 hour
$client->upload('photo.jpg', ['expires_in' => 3600]);

// Upload from an already-open resource
$handle = fopen('photo.jpg', 'rb');
$client->upload($handle, ['filename' => 'photo.jpg']);

// List your uploads (paginated, 50 per page)
$listing = $client->list();
foreach ($listing->data as $item) {
    echo $item->id . ' ' . $item->direct . PHP_EOL;
}

// Delete an upload
$client->delete($result->id);

Error handling

Failed requests throw YourImageShare\YourImageShareError (getStatus() is the HTTP status code, getApiMessage() is the server's error text):

use YourImageShare\YourImageShare;
use YourImageShare\YourImageShareError;

$client = new YourImageShare('YOUR_API_KEY');

try {
    $client->upload('photo.jpg');
} catch (YourImageShareError $e) {
    echo $e->getStatus() . ': ' . $e->getApiMessage();
}

API

new YourImageShare(string $apiKey, string $baseUrl = YourImageShare::DEFAULT_BASE_URL, int $timeout = 30)

$baseUrl defaults to https://yourimageshare.com/api - override only for testing against a different environment.

$client->upload($file, array $options = [])

$file is a path (string) or an open resource (from fopen()). $options['expires_in'] is seconds, 60 to 2,592,000 (30 days) - omit for a permanent upload. $options['filename'] is required when $file is a resource without an obvious name. Returns an UploadResult with id, type, path, src, direct, expiresAt.

$client->list(int $page = 1)

Returns a ListResult with data (an array of ListedUpload - id, type, title, path, src, direct, expiresAt, createdAt) and meta (ListMeta - currentPage, lastPage, total).

$client->delete(string $id)

Throws YourImageShareError on a 404/401; returns void on success.

Rate limits

20 requests/minute and 500/day per key by default (2,000/day per IP as a backstop). Not currently surfaced on the return values from this SDK - read the X-RateLimit-Limit/X-RateLimit-Remaining response headers yourself if you need them, or open an issue to request them on the result objects.

License

MIT

Support

yourimageshare.com/contact