Last active
March 27, 2024 05:01
-
-
Save scarnecchia/43922a2ebc238dccf33ab4fa296aeda3 to your computer and use it in GitHub Desktop.
This works for posting an image to bsky from the CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accessJwt=$(curl -X POST https://bsky.social/xrpc/com.atproto.server.createSession \ | |
-H "Content-Type: application/json" \ | |
-d '{"identifier": "'"$BLUESKY_HANDLE"'", "password": "'"$BLUESKY_APP_PASSWORD"'"}' | jq -j ".accessJwt") | |
blob=$(curl -X POST 'https://bsky.social/xrpc/com.atproto.repo.uploadBlob' \ | |
-H "Authorization: Bearer $accessJwt" \ | |
-H 'Content-Type: image/jpeg' \ | |
--data-binary "@alf.jpg" | jq -r ".blob") | |
# link=$(echo "$blob" | jq -r '.blob.ref."$link"') | |
# size=$(echo "$blob" | jq -r '.blob.size') | |
text="I've always been sensual." | |
curl -X POST https://bsky.social/xrpc/com.atproto.repo.createRecord \ | |
-H "Authorization: Bearer $accessJwt" \ | |
-H "Content-Type: application/json" \ | |
-d "{ \"repo\": \"$BLUESKY_HANDLE\", \"collection\": \"app.bsky.feed.post\", \"record\": { \"text\": \"$text\", \"embed\": { \"\$type\": \"app.bsky.embed.images\", \"images\": [{ \"alt\": \"Sensual Alf\", \"image\": $blob }] }, \"createdAt\": \"1986-09-22T21:00:00.001Z\" }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment