Skip to content

Instantly share code, notes, and snippets.

@scarnecchia
Last active March 27, 2024 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarnecchia/43922a2ebc238dccf33ab4fa296aeda3 to your computer and use it in GitHub Desktop.
Save scarnecchia/43922a2ebc238dccf33ab4fa296aeda3 to your computer and use it in GitHub Desktop.
This works for posting an image to bsky from the CLI
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