Skip to content

Quick Start

Eldar Shahmaliyev edited this page Jan 27, 2025 · 6 revisions

Installation

You can install the package with composer:

composer require shahmal1yev/blueskysdk:"^1@beta"

Authentication

Authenticate to BlueSky easily with your credentials.

use Atproto\Client;

$client = new Client();
$client->authenticate(getenv('BLUESKY_IDENTIFIER'), getenv('BLUESKY_PASSWORD'));

Save and Restore Sessions

Export the session for later use:

$saveToDatabase(json_encode($client->authenticated()));

Restore it when needed:

use Atproto\Responses\Com\Atproto\Server\CreateSessionResponse;

$savedSession = new CreateSessionResponse(json_decode($savedSessionJSON, true));

$client = new Client();
$client->authenticate(getenv('BLUESKY_IDENTIFIER'), getenv('BLUESKY_PASSWORD'), $savedSession);

Making a Request

Use the BskyFacade for clean and concise API requests:

$profile = bskyFacade($client)->getProfile()
    ->actor($client->authenticated()->handle())
    ->send();

echo $profile->displayName(); // Type-safe response

Casting Example

Access response data with type casting:

/** @var \Carbon\Carbon $createdAt */
$createdAt = $profile->createdAt();

Full Example

$session = new CreateSessionResponse(json_encode(/* session json */, true));
$client = new Client('identifier', 'password', $session);

$profile = bskyFacade($client)->getProfile()
    ->actor($client->authenticated()->handle())
    ->send();

$createdAt = $profile->createdAt();
  • 🏠 Home
    Introduction to the SDK and its features

  • 🚀 Quick Start
    Get started quickly with the basics of using the Bluesky SDK

  • ⚙️ Installation
    Step-by-step guide to installing the SDK

  • 🛠️ Architecture Overview
    Learn about the SDK's structure and design principles

  • 📖 BskyFacade
    Simplify API interactions with the facade

  • 💾 Serialization
    Serialize and deserialize data effectively

  • 🔄 Session Management
    Manage authentication and session reuse

  • 🧹 Casting
    Explore type-safe response casting in the SDK

  • 💡 Examples
    Practical usage examples for various features

Clone this wiki locally