curl https://b-sky.deno.dev?identifier=laravel11.bsky.social&password=PASSWORD&text=やあ
laravel11.bsky.social
とPASSWORD
は適宜書き換えてね!
https://bsky.app/profile/laravel11.bsky.social
See the Pen Bluesky Post by John Doe (@04) on CodePen.
ソースコード
import AtprotoAPI from 'npm:@atproto/api'
Deno.serve(async (req: Request) => {
const headers = { 'Access-Control-Allow-Origin': '*' }
const { identifier, password, text = 'こんにちは!', service = 'https://bsky.social' } = Object.fromEntries(new URL(req.url).searchParams)
try {
const agent = new AtprotoAPI.BskyAgent({ service })
await agent.login({ identifier, password })
const richText = new AtprotoAPI.RichText({ text })
await richText.detectFacets(agent)
const response = await agent.post({
$type: 'app.bsky.feed.post',
text: richText.text,
facets: richText.facets,
})
return Response.json(response, { headers })
} catch (e) {
return new Response(e.message, { status: 400, headers })
}
});