Created
November 17, 2022 16:23
-
-
Save bitbonk/f18fe5109c2a26ca83ea22e800730f2e to your computer and use it in GitHub Desktop.
Using Masto.NET in Azure Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RepostOnMastodon | |
{ | |
private readonly AuthenticationClient client; | |
public RepostOnMastodon() | |
{ | |
this.client = new AuthenticationClient("something.social"); | |
} | |
[FunctionName("RepostOnMastodon")] | |
public async Task Run([TimerTrigger("* * * * *")] TimerInfo myTimer, ILogger log) | |
{ | |
var appRegistration = | |
await this.client.CreateApp("[email protected] reposter", Scope.Read | Scope.Write | Scope.Follow); | |
var auth = await this.client.ConnectWithCode("mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6kg"); | |
var mastoClient = new MastodonClient(appRegistration, auth); | |
var result = await mastoClient.PostStatus($"Hello, current time is {DateTime.Now}", Visibility.Direct); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment