Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joeymckenzie/bluesky-php
A PHP client for the Bluesky social network API. 🦋
https://github.com/joeymckenzie/bluesky-php
bluesky php
Last synced: 2 months ago
JSON representation
A PHP client for the Bluesky social network API. 🦋
- Host: GitHub
- URL: https://github.com/joeymckenzie/bluesky-php
- Owner: JoeyMckenzie
- License: mit
- Created: 2024-11-03T21:34:05.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-12T23:16:35.000Z (2 months ago)
- Last Synced: 2024-11-13T00:20:16.728Z (2 months ago)
- Topics: bluesky, php
- Language: PHP
- Homepage: https://packagist.org/packages/joeymckenzie/bluesky-php
- Size: 692 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Bluesky PHP
> This package is still in early development, with no major releases at the moment. Use with precaution!
A Bluesky PHP client compatible with your HTTP client of choice. The goal of this project is to provide a simple,
easy-to-use PHP HTTP client to interact with [Bluesky's API](https://docs.bsky.app/), providing methods for calling
both the authenticated and public endpoints.## Bluesky PHP in action
```php
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();// Option 1, we can manually a session and forward the token
$session = $client->session()->createSession($password);
var_dump($session);$profile = $client->actor()->getProfile($username);
var_dump($profile);// OR option 2, create a new session through the client instance
$newSession = $client->newSession($password);
var_dump($newSession);$profile = $client->actor()->getProfile($username);
var_dump($profile);// Create a post
$post = $client->feed()->post('This post was brought to you by PHP!');
```## Getting started
To get started, install Bluesky from Packagist
```shell
$ composer install joeymckenzie/bluesky-php
```Within you code, instantiate a new instance of the client:
```php
$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 require authentication
$publicClient = Bluesky::publicClient();
```## Status
The API surface of Bluesky's API is fairly large encompassing some odd 160ish different endpoints. A complete list can
be found within the [TODO](TODO.md) list, containing simple tracking of endpoints that have been implemented and those
yet to be implemented.## Testing
To run tests
```shell
$ composer run test
```Bluesky PHP uses [Pest](https://pestphp.com/) for testing, where each endpoint contains a test that:
- Verifies the call as we expect to Bluesky
- Verifies the properties on the responseYou'll find test data within the [fixtures](tests/Fixtures) folder, container stubs with randomly generated
fake data mimicking data received from the API at various endpoints.