PHP code example of joeymckenzie / bluesky-php

1. Go to this page and download the library: Download joeymckenzie/bluesky-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

joeymckenzie / bluesky-php example snippets




declare(strict_types=1);

use Bluesky\Bluesky;

/');
$dotenv->load();

// By default, the client assumes we're going to authenticate as a valid user
$username = $_ENV['BLUESKY_USERNAME'];
$password = $_ENV['BLUESKY_PASSWORD'];

// Construct the client using the default builder with no customizations
$client = Bluesky::client($username);

// It's also possible to use the public API as well
$publicApi = Bluesky::publicClient();

// Next, create a new session for the API
$session = $client->newSession($password);
var_dump($session);

$profile = $client->bsky()->actor()->getProfile($username);
var_dump($profile);

// Create a post
$post = $client->bsky()->feed()->post('This post was brought to you by PHP. Working on yet another Bluesky client for PHP, heavily inspired Nuno\'s OpenAI client. Coming to a Packagist feed near you... 🤠');

$client = Bluesky::client('username.bsky.social');

// To use the client, you'll need to create a new session that'll grab some JWTs for authentication
$client->newSession('password123');

// Or, build a new client with a session
$clientWithSession = Bluesky::clientWithSession('username.bsky.social', 'password123');

// Or, using the public API client that doesn't 
shell
$ composer install joeymckenzie/bluesky-php