mov / php-bluesky
A simple php api client for bluesky
0.2.0
2024-01-31 12:23 UTC
Requires
- symfony/http-client: ^7.0
This package is auto-updated.
Last update: 2024-10-30 01:54:15 UTC
README
Installation
composer require mov/php-bluesky:dev-main
Basic Usage
// Simple text post $blueskyClient = new BlueskyClient(); $blueskyClient->authenticate('<YOUR BLUESKY HANDLE>', '<YOUR APP PASSWORD>'); $blueskyClient->post('Post something.'); // Upload image and post it $blueskyClient = new BlueskyClient(); $blueskyClient->authenticate('<YOUR BLUESKY HANDLE>', '<YOUR APP PASSWORD>'); $image = file_get_contents('<PATH/TO/IMAGE>'); $contentType = mime_content_type('<PATH/TO/IMAGE>'); $responseJson = $blueskyClient->uploadBlob($image, $contentType); $response = json_decode($responseJson, true); $embed = [ '$type' => 'app.bsky.embed.images', 'images' => [ [ 'alt' => 'A test image', 'image' => $response['blob'], ], ] ]; $blueskyClient->post('Additional text', $embed);