开源软件名称(OpenSource Name):yamachu/Mastodot开源软件地址(OpenSource Url):https://github.com/yamachu/Mastodot开源编程语言(OpenSource Language):C# 100.0%开源软件介绍(OpenSource Introduction):Mastodot - Mastodon API library for C# (.NET)日本語はこちら Sample codeSee example Sample code contains how to generate tokens, toot, and subscribe stream. Regist an app to Mastodon Instancevar registeredApp = await ApplicationManager.RegistApp("Host name" /* ex: mastodon.cloud */, "Your Application Name", Scope.Read | Scope.Write | Scope.Follow);
registeredApp contains ClienID and ClientSecret. Login and get AccessToken// if login by email
var tokens = ApplicationManager.GetAccessTokenByEmail(registeredApp, "Email", "Password");
// if login by use OAuth
var url = ApplicationManager.GetOAuthUrl(registeredApp);
// access this url via browser, HttpClient, ...
var tokens = await ApplicationManager.GetAccessTokenByCode(registeredApp, "Code that Browser shows");
tokens contains AccessToken. You can access Mastodon API by using this AccessToken. Using Mastodon APIThis code is how to Toot. var client = new MastodonClient("Host name (url)", tokens.AccessToken);
client.PostNewStatus(status: "Hello Mastodon!");
// With media
var attachment = await client.UploadMedia("File Path");
client.PostNewStatus("Look my cuuuuute dog!", mediaIds: new int[]{attachment.Id});
and Using StreamAPI var publicStream = client.GetObservablePublicTimeline()
.OfType<Status>()
.Subscribe(x => Console.WriteLine($"{x.Account.FullUserName} Tooted: {x.Content}"));
MastodonAPIsMastodon APIsAll APIs is ready Accounts
Apps
Blocks
Favourites
Follow Requests
Follows
Instances
Media
Mutes
Notifications
Reports
Search
Statuses
Timelines
Streaming
LicenseMIT OtherWelcode pull requests! For developerFor support multi target frameworks, When edit and debug this library, replace |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论