Replying to another status
The example below creates a new MastodonHttpService
instance from an access token, and then attempts to post two new statuses where the second is a reply to the first:
@using Skybrud.Social.Mastodon
@using Skybrud.Social.Mastodon.Exceptions
@using Skybrud.Social.Mastodon.Models.Statuses
@using Skybrud.Social.Mastodon.Options.Statuses
@using Skybrud.Social.Mastodon.Responses.Statuses
@{
// Initialize a new HTTP service (basically the API wrapper)
MastodonHttpService mastodon = MastodonHttpService
.CreateFromAccessToken("umbracocommunity.social", "Your access token");
<h3>First</h3>
MastodonStatus first;
try {
MastodonStatusResponse response = await mastodon.Statuses.PostStatusAsync(new MastodonPostStatusOptions {
Status = "Hello world! #test"
});
first = response.Body;
<pre>@first.JObject</pre>
} catch (MastodonHttpException ex) {
<pre>@ex</pre>
<pre>@ex.Error</pre>
<pre>@ex.Response.Body</pre>
return;
} catch (Exception ex) {
<pre>@ex</pre>
return;
}
<h3>Second</h3>
try {
MastodonStatusResponse response = await mastodon.Statuses.PostStatusAsync(new MastodonPostStatusOptions {
Status = "Hej verden! #test",
InReplyTo = first.Id
});
var second = response.Body;
<pre>@second.JObject</pre>
} catch (MastodonHttpException ex) {
<pre>@ex</pre>
<pre>@ex.Error</pre>
<pre>@ex.Response.Body</pre>
return;
} catch (Exception ex) {
<pre>@ex</pre>
return;
}
}