1. Go to this page and download the library: Download williamsdb/php2bluesky 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/ */
williamsdb / php2bluesky example snippets
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);
$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;
}
$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;
}
$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;
}
$response = $php2Bluesky->post_to_bluesky(connection: $connection,
text: $text = "this is the text of your post",
media: $media = "https://www.spokenlikeageek.com/wp-content/uploads/2025/06/SCR-20250628-jzfa.png",
link: $link = '',
alt: $alt = "Image of labels applied to a Bluesky post",
labels: $labels = ["!no-unauthenticated", "porn", "sexual"]);
$text = "This is some text to which only @spokenlikeageek.com can reply.";
$response = $php2Bluesky->post_to_bluesky($connection, $text);
$php2Bluesky->add_restrictions($connection, $response, 'Mention');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.