Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/naamloos/phanagoroloxodon
More dead elephants. (.NET 8 library for Mastodon)
https://github.com/naamloos/phanagoroloxodon
csharp mastodon mastodon-api net8 netcore
Last synced: about 2 months ago
JSON representation
More dead elephants. (.NET 8 library for Mastodon)
- Host: GitHub
- URL: https://github.com/naamloos/phanagoroloxodon
- Owner: Naamloos
- License: mit
- Created: 2024-02-18T19:08:32.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-10-15T21:09:19.000Z (2 months ago)
- Last Synced: 2024-10-31T05:04:51.024Z (about 2 months ago)
- Topics: csharp, mastodon, mastodon-api, net8, netcore
- Language: C#
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Phanagoroloxodon
More dead elephants. (.NET 8 library for Mastodon)Phanagoroloxodon was made because all the existing libraries for .NET either are ancient or suck ass. As of right now, the focus is on the REST api, but support for websocket-based streaming API is planned.
## Namesake
As Mastodon is named after an extinct species of elephants, I decided to name my library after an extinct elephant genus. Hence "more dead elephants". [Wikipedia: Phanagoroloxodon](https://en.wikipedia.org/wiki/Phanagoroloxodon).## Getting started
The library is still very much in development, and thus is not available on Nuget yet.```cs
// Authenticating a Mastodon client using a pre-generated access token.
var mastodon = new Mastodon(new MastodonClientConfig()
{
AccessToken = "your-token",
Instance = "yourinstance.social"
});// Posting a simple text status
var tootResponse = await mastodon.PostStatusAsync("Hello world!");
if(!tootResponse.Success)
{
// Leave error handling to the end user!
Console.WriteLine(tootResponse.Error);
}// Fetching timeline
var timelineResponse = await mastodon.GetPublicTimelineAsync();
if(publicTimeline.Success)
{
foreach(Status toot in timelineResponse.Value)
{
// Prints out last public toots to the console.
Console.WriteLine($"{toot.Account.Acct}:\n{toot.SanitizedContent}\n\n");
}
}
```It's really that simple. I hated how other libs did it so I decided to build my own. SanitizedContent may be somewhat inaccurate due to lack of testing, but it uses [HTML Agility Pack](https://html-agility-pack.net/) for getting a plaintext version of status content.