scripting / blue.feedland

A place to discuss and develop an app that connects social media apps via feeds.
MIT License
5 stars 0 forks source link

BlueSky API -- more questions #15

Open scripting opened 1 year ago

scripting commented 1 year ago

Getting the URL of a new post

When I create a new post via the BlueSky API, I get back the following info:

{ "uri": "at://did:plc:mfrjt4jqlhx65hokv5yv7tj7/app.bsky.feed.post/3jy2ia5m5vw2e", "cid": "bafyreibvcvyq4r6kredtoirkny7mi6pemp336elm5lvn7ysaxaq6zmwaku" }

How can I get the actual HTTP url for the post, so I can provide it to the user?

Information about a user?

Avatar, name, description, whatever else is public.

What is the character limit for a post? (answered below)

I'm using 280, but I think it's 300? Or 500.

Any help much appreciated. :smile:

scripting commented 1 year ago

The last question was answered -- it's 300.

But it appears in the software that it's a pretty soft number because some characters are actually two.

So in the software I set it at 280 and made it user-configurable. The ultimate cop out -- you want all the chars in each post, then set it to 300 but be forewarned there will be some sketchy behavior. We really need to get rid of character limits is the moral of this story.

chriszarate commented 1 year ago

"uri": "at://did:plc:mfrjt4jqlhx65hokv5yv7tj7/app.bsky.feed.post/3jy2ia5m5vw2e", How can I get the actual HTTP url for the post, so I can provide it to the user?

If you know the handle, you can construct the URL since the post id is the last identifier in the at:// URI above:

https://bsky.app/profile/<handle>.bsky.social/post/<post_id>

Example: https://bsky.app/profile/davew.bsky.social/post/3jy5b3p5rfc2r

scripting commented 1 year ago

@chriszarate -- i don't have the user's <handle>.

I think that's related to the second issue. ;-)

Here's the info I do have...

image
chriszarate commented 1 year ago

Gotcha. The authority / "hostname" portion of the at:// URI represents the DID (decentralized identifier). I don't have a an API integration up and running but we can get user info using that.

Here's an example service that performs handle lookup from DIDs (among other things).

> curl 'https://bsky.link/getfeed?handle=did:plc:mfrjt4jqlhx65hokv5yv7tj7'
{"handle":"bingeworthy.bsky.social"}

Now we can resolve the URL of the example you posted:

https://bsky.app/profile/bingeworthy.bsky.social/post/3jy2ia5m5vw2e

That tool is open source and this looks to be the relevant code. Seems promising as a way to get additional profile info:

https://github.com/capjamesg/bsky.link/blob/38daf5d4c3674a28af3d10cd88424bb0832b12ff/app.js#L361