在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):pawotter/mastodon-api-cs开源软件地址(OpenSource Url):https://github.com/pawotter/mastodon-api-cs开源编程语言(OpenSource Language):C# 100.0%开源软件介绍(OpenSource Introduction):Mastodon API client library for C#The Mastodon API Client Library for C# (PCL 4.5, Profile 111) Pull reqeusts are always welcome! master branchdevelop branchInstall
Registering an app to Mastodon instancevar authClient = new MastodonAuthClient(new Uri("https://friends.nico"));
var redirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob");
var scope = OAuthAccessScope.of(OAtuhAccessScopeType.Read);
var app = await authClient.CreateApp("client_name", redirectUri, scope); A registered OAuth application is assigned a unique Client ID and Client Secret. Login with email address and passwordNot recommended to use in service. The Authorization Code Grant flow is recommended for applications. var token = await authClient.GetOAuthToken(app.ClientId, app.ClientSecret, "username", "password", scope); Making API Callsvar config = new MastodonApiConfig(instanceUrl, token.AccessToken);
var api = new MastodonApi(config);
var account = await api.GetCurrentAccount(); Error HandlingAll error responses are thrown as the type MastodonApiException. Please be sure to catch this in your code and respond to any error condtions appropriately. try
{
// api calls here
}
catch (MastodonApiException e)
{
// error handling here (i.e., no results found, login failed, server error, etc)
} LicenseMIT Authorgomi_ningen (@53ningen) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论