revolution / laravel-bluesky
Bluesky(AT Protocol) for Laravel
Installs: 2 873
Dependents: 0
Suggesters: 0
Security: 0
Stars: 30
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- firebase/php-jwt: ^6.10
- guzzlehttp/guzzle: ^7.8
- illuminate/support: ^11.30
- jetbrains/phpstorm-attributes: ^1.2
- laravel/socialite: ^5.16
- phpseclib/phpseclib: ^3.0
- revolution/atproto-lexicon-contracts: 1.0.39
- valtzu/guzzle-websocket-middleware: ^0.2.0
- yocto/yoclib-multibase: ^1.2
Requires (Dev)
- larastan/larastan: ^3.0
- orchestra/testbench: ^9.0
- phpstan/extension-installer: ^1.4
Suggests
- ext-gmp: *
- ext-pcntl: *
- dev-main
- 0.15.1
- 0.15.0
- 0.14.17
- 0.14.16
- 0.14.15
- 0.14.14
- 0.14.13
- 0.14.12
- 0.14.11
- 0.14.10
- 0.14.9
- 0.14.8
- 0.14.7
- 0.14.6
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.8
- 0.13.7
- 0.13.6
- 0.13.5
- 0.13.4
- 0.13.3
- 0.13.2
- 0.13.1
- 0.13.0
- 0.12.9
- 0.12.8
- 0.12.7
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.9
- 0.10.8
- 0.10.7
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.16
- 0.7.15
- 0.7.14
- 0.7.13
- 0.7.12
- 0.7.11
- 0.7.10
- 0.7.9
- 0.7.8
- 0.7.7
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-labeler
- dev-analysis-16QrE3
- dev-analysis-32leZ5
- dev-car
- dev-cid
- dev-tid
- dev-analysis-Q3AdGm
- dev-ecc
- dev-crypto
This package is auto-updated.
Last update: 2024-12-25 12:56:09 UTC
README
Work in progress
Requirements
- PHP >= 8.2
- Laravel >= 11.x
Installation
composer require revolution/laravel-bluesky
Basically, everything can be set in the .env
file, so publishing the config file is optional.
Uninstall
composer remove revolution/laravel-bluesky
Quick start
Search posts (no auth required, no need for your own account)
There are many public APIs that do not require authentication if you just want to retrieve data.
// routes/web.php use Illuminate\Support\Facades\Route; use Revolution\Bluesky\Facades\Bluesky; Route::get('search', function () { /** @var \Illuminate\Http\Client\Response $response */ $response = Bluesky::searchPosts(q: '#bluesky', limit: 10); $response->collect('posts') ->each(function (array $post) { dump(data_get($post, 'author.displayName')); dump(data_get($post, 'author.handle')); dump(data_get($post, 'author.did')); dump(data_get($post, 'record.text')); }); });
Get someone's posts (no auth required)
// routes/web.php use Illuminate\Support\Facades\Route; use Revolution\Bluesky\Facades\Bluesky; Route::get('feed', function () { // "actor" is did(did:plc:***) or handle(***.bsky.social, alice.test) $response = Bluesky::getAuthorFeed(actor: '***.bsky.social'); $response->collect('feed') ->each(function (array $feed) { dump(data_get($feed, 'post.author.displayName')); dump(data_get($feed, 'post.record.text')); }); });
You can get your own posts by specifying your did or handle as the actor. No authentication is required to get and save your own posts.
Create a post (requires auth)
There are two authentication methods for Bluesky: "App password" and "OAuth". Here we will use "App password". Obtain the App password from Bluesky and set it in .env.
// .env
BLUESKY_IDENTIFIER=***.bsky.social
BLUESKY_APP_PASSWORD=****-****-****-****
// routes/web.php use Illuminate\Support\Facades\Route; use Revolution\Bluesky\Facades\Bluesky; Route::get('post', function () { $response = Bluesky::login(identifier: config('bluesky.identifier'), password: config('bluesky.password')) ->post('Hello Bluesky'); });
This is easy if you're just sending simple text, but in the real world you'll need to use TextBuilder
to make links and tags work.
// routes/web.php use Illuminate\Support\Facades\Route; use Revolution\Bluesky\Facades\Bluesky; use Revolution\Bluesky\Record\Post; use Revolution\Bluesky\RichText\TextBuilder; Route::get('text-builder', function () { $post = Post::build(function (TextBuilder $builder) { $builder->text('Hello Bluesky') ->newLine(count: 2) ->link('https://bsky.app/') ->newLine() ->tag('#Bluesky'); }); $response = Bluesky::login(identifier: config('bluesky.identifier'), password: config('bluesky.password')) ->post($post); });
Following message will be posted:
Hello Bluesky
https://bsky.app/
#Bluesky
To authenticate with OAuth, read the Socialite documentation.
Usage
Advanced
Contracts
https://github.com/kawax/atproto-lexicon-contracts
LICENCE
MIT