Bluesky is a decentralized social network based on an open protocol called the AT Protocol, allowing users to control their data and interactions. Unlike centralized platforms, Bluesky enables different instances (servers) to connect, offering greater freedom and customization. The goal is to create a more transparent environment where users can share information and interact without the constraints of traditional networks. Each instance has its own rules, allowing for a diversity of opinions and communities.
After this introduction to the Bluesky service, let’s learn how to publish a post on the Bluesky network using PHP.
Prerequisites
You need to obtain an application password.
To do this:
- Log in to your Bluesky instance.
- Go to the “Settings” menu.
- Navigate to “Privacy and Security.”
- Select “App Passwords.”
- Click on the “Add App Password” button.
- Define the name of the application: in our case, we’ll call it “BlueskyBot.”
- Click the “Next” button.
- Retrieve your app password.
Theory
We will use the Bluesky API, whose documentation is available online.
Implementation
The implementation will be done in PHP 8.4 with the Curl extension installed and enabled.
|
|
This code is the simplest implementation possible, as you can see, without using any library and with minimal extensions.
Conclusion
After a simple execution of the code, here is the result:
With the documentation, there are several possible improvements to make:
- Detect mentions/URLs in the text and implement them in the code.
- Add the ability to quote a post.
- Include images in a post.
- Add a social card to a post.