dotnet new console -n HelloBluesky
cd HelloBluesky
dotnet add package idunno.Bluesky --prerelease
Create a new .NET Command Line project by opening the File menu, and choosing New ▶ Project.
In the "Create a new project" dialog select C# as the language, choose Console App as the project type then click Next.
In the "Configure your new project" dialog name the project HelloBluesky and click Next.
In the "Additional information" dialog choose a Framework as .NET 8.0, uncheck the "Do not use top level statements" check box then click Create.
Under the Project menu Select Manage nuget packages, select the Browse tab, ensure that the Include prelease checkbox is checked. Search for idunno.Bluesky, and click Install.
Open the Program.cs file in your editor of choice and change its contents to the following code, replacing
the "handle" and "password" parameters in the agent.Login() call with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
Save the changed file.
Open the Program.cs file from the Solution Explorer window and change its contents to the following code, replacing
the "handle" and "password" parameters for in the agent.Login() call with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
Save the changed file.
Open the Program.cs file from the Explorer window and change its contents to the following code, replacing
the "handle" and "password" parameters for the agent.Login() method with your Bluesky handle and password.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
Save the changed file.
Open
Tip
You can create and use an App password instead of your login password.
App Passwords are safer as they allow sign in without granting full access to your Bluesky account.
Continue to change Program.cs by adding an additional line to create a post.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
await agent.Post("Hello World from idunno.Bluesky");
Save the changed file and exit your editor.
Compile and run your project with the following command
dotnet run
Continue to change Program.cs by adding an additional line to create a post.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
await agent.Post("Hello World from idunno.Bluesky");
Save the changed file.
Run the project by pressing F5 or choosing Start Debugging under the Debug menu.
Continue to change Program.cs by adding an additional line to create a post.
using idunno.Bluesky;
using BlueskyAgent agent = new();
await agent.Login(handle, password);
await agent.Post("Hello World from idunno.Bluesky");
Save the changed file.
Run the project by pressing F5 or choosing Start Debugging under the Run menu.
The program should run without any errors, and if you check your own profile (click the Profile link in the app, or on bsky.app)
you should see a post that says "Hello World from idunno.Bluesky".
Congratulations, you've just posted from code!
You can @ someone in the post text, add hashtags, or http/https links and they will all get turned into the right type of link. Try it and check in the app.