AD
Boost Your Brand on BlueSky—Exclusive banner space to amplify your reach within the BlueSky community.
BSkyInfo LogoBskyInfo
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryArticlesGuidesGlossaryBluesky SDKsSponsor
Submit
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryGuidesGlossaryArticlesBluesky SDKsSponsorSubmit
  1. SDKs
  2. /PHP
  3. /php2Bluesky
williamsdb

php2Bluesky

A PHP SDK for Bluesky and AT Protocol by williamsdb

Helper library to post to Bluesky Social

GitHub Stats

14stars
5forks
5contributors
2open issues

Dates

Created:November 9, 2023
Last updated:May 8, 2025

README

The following content is from php2Bluesky's GitHub repository. All rights reserved by the original author.


php2Bluesky

A simple library that allows posting to Bluesky via the API.

Table of Contents
  1. About The Project
    • Built With
  2. Getting Started
    • Prerequisites
    • Installation
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

With all the uncertainty surrounding the future of X (née Twitter), I decided to take a look at Bluesky, which somewhat ironically has its roots in Twitter, where it was started as an internal project. I worry about Bluesky's long-term, given that ultimately it too has to make money, something that Twitter has singularly failed to do. None of this, of course, affects the topic today, which is posting to Bluesky via the API.

I needed a way to post to Bluesky from PHP and so I searched for a library to help and when I couldn't find one I wrote this.

Buy Me a Coffee at ko-fi.com

(back to top)

Built With

  • PHP
  • BlueskyApi by Clark Rasmussen

(back to top)

Getting Started

NOTE This is for v2 of php2Bluesky. If you are looking for the v1 details you can find that here.

Running the script is very straightforward:

  1. install composer
  2. add the BlueskyAPI

composer.phar require cjrasmussen/bluesky-api

  1. add php2Bluesky

composer.phar require williamsdb/php2bluesky

Now you can inspect example.php to get some examples and/or see below.

If you are interested in what is happening under the hood then read this series of blog posts.

Prerequisites

Requirements are very simple, it requires the following:

  1. PHP (I tested on v8.1.13) - requires php-dom and php-gd
  2. Clark Rasmussen's BlueskyApi (requires v2 or above)
  3. a Bluesky account and an Application Password (see this blog post for details of how to do that)
  4. ffprobe if you intend to upload videos.

Read more about the requirements for video upload here.

Installation

  1. As above

(back to top)

Usage

Here's a few examples to get you started.

Note: connection to the Bluesky API is made via Clark Rasmussen's BlueskyApi which this makes a connection to Bluesky and manages tokens etc. See here for more details.

  • Setup and connect to Bluesky:
require __DIR__ . '/vendor/autoload.php';

use williamsdb\php2bluesky\php2Bluesky;

$php2Bluesky = new php2Bluesky();

$handle = 'yourhandle.bsky.social';
$password = 'abcd-efgh-ijkl-mnop';
    
// connect to Bluesky API
$connection = $php2Bluesky->bluesky_connect($handle, $password);
  • Sending text with tags
$text = "This is some text with a #hashtag.";

$response = $php2Bluesky->post_to_bluesky($connection, $text);
print_r($response);
if (!isset($response->error)){
    $url = $php2Bluesky->permalink_from_response($response, $handle);
    echo $url.PHP_EOL;            
}
  • Uploading a post with a single image and embedded url
$filename1 = 'https://upload.wikimedia.org/wikipedia/en/6/67/Bluesky_User_Profile.png';
$text = 'Screenshot of Bluesky';
$alt = 'This is the screenshot that Wikipedia uses for their https://en.wikipedia.org/wiki/Bluesky entry.';

$response = $php2Bluesky->post_to_bluesky($connection, $text, $filename1, '', $alt);
print_r($response);
if (!isset($response->error)){
    $url = $php2Bluesky->permalink_from_response($response, $handle);
    echo $url.PHP_EOL;            
}
  • Uploading a post with multiple images (both local and remote)
$filename1 = 'https://upload.wikimedia.org/wikipedia/en/6/67/Bluesky_User_Profile.png';
$filename2 = '/Users/neilthompson/Development/php2Bluesky/Screenshot1.png';
$filename3 = 'https://www.spokenlikeageek.com/wp-content/uploads/2024/11/2024-11-18-19-28-59.png';
$filename4 = '/Users/neilthompson/Development/php2Bluesky/Screenshot2.png';
$text = 'An example of four images taken both from a local machine and remote locations with some alt tags';
    
// send multiple images with text
$imageArray = array($filename1, $filename2, $filename3, $filename4); 
$alt = array('this has an alt', 'so does this');
    
$response = $php2Bluesky->post_to_bluesky($connection, $text, $imageArray, '', $alt);
print_r($response);
if (!isset($response->error)){
    $url = $php2Bluesky->permalink_from_response($response, $handle);
    echo $url.PHP_EOL;            
}
  • Uploading a post with a single video
$filename1 = '/path/to/local/video.mp4';
$text = 'A beautiful video';

$response = $php2Bluesky->post_to_bluesky($connection, $text, $filename1);
print_r($response);
if (!isset($response->error)){
    $url = $php2Bluesky->permalink_from_response($response, $handle);
    echo $url.PHP_EOL;            
}
  • Sending parameters when connecting to override defaults
$php2Bluesky = new php2Bluesky($linkCardFallback = 'RANDOM', 
                               $failOverMaxPostSize = FALSE, 
                               $randomImageURL = 'https://picsum.photos/1024/536',
                               $fileUploadDir='/tmp');

(back to top)

Known Issues

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Thanks to the follow who have provided techincal and/or financial support for the project:

  • Jan Strohschein
  • Ludwig Noujarret
  • Paul Lee
  • AJ
  • https://bsky.app/profile/bobafettfanclub.com
  • Doug "Bear" Hazard

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GNU General Public License v3.0. See LICENSE for more information.

(back to top)

Contact

Bluesky - @spokenlikeageek.com

Mastodon - @spokenlikeageek

X - @spokenlikeageek

Website - https://spokenlikeageek.com

Project link - Github

(back to top)

Acknowledgments

  • BlueskyApi

(back to top)

Related SDKs

shahmal1yevblueskysdk

BlueSky SDK is a comprehensive PHP library designed to seamlessly integrate with the BlueSky social network.

29•PHP
cjrasmussenBlueskyApi

Simple helper for interacting with the Bluesky API/AT protocol

37•PHP
potibmphluesky

An small PHP library for Bluesky social using the AT Protocol.

34•PHP
aazsamirlibphpsky

Libphpsky is a PHP library designed to interact with Bluesky decentralized social media protocol - AT protocol.

5•PHP
sbm12bsky-Pack2List

Converting a BlueSky Starter Pack to User List

25•PHP
socialweb-phpatproto

A PHP library for integrating with and communicating over the AT Protocol

42•PHP

Resources

GitHub Repository

License

GPL-3.0

Author

williamsdb
williamsdb

Activity

Last commit: May 8, 2025
Commit frequency: Unknown

Our Sponsors

Your Brand Here!

50K+ engaged viewers every month

Limited spots available!

📧 Contact us via email🦋 Contact us on Bluesky
BSkyInfo LogoBskyInfo

The Most Comprehensive Bluesky Tools Directory

Stay updated with the latest Bluesky tools and ecosystem news 🦋

Bluesky butterfly logo
Quick LinksSubmit a ToolSponsorAboutLegal Information
ToolsFeed DirectoryLabeler DirectorySchedulingAnalyticsAll ToolsCategoriesCollectionsTags
ResourcesArticlesBluesky GuidesBluesky GlossaryBluesky SDKsBluesky ResourcesSkyRaffleMeida Coverage
Our ProductsRaffleBlueAiTeach ToolsLaiewAI affiliate listFirsto

This website may contain affiliate links

© 2025 BskyInfo. All rights reserved.