-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ : Add new function / Noteを送信できるように。
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
using MisskeyDotNet.Object; | ||
|
||
namespace MisskeyDotNet.WebAPI; | ||
|
||
public class MiWebAPI | ||
{ | ||
HttpClient client = new(); | ||
string _url = "https://misskey.io/api"; | ||
string _token = ""; | ||
|
||
public MiWebAPI(String token, String baseURL = "misskey.io") | ||
{ | ||
_token = token; | ||
_url = $"https://{baseURL}/api"; | ||
} | ||
|
||
public async Task<string> Note(String token, MiSendNote miSendNote) | ||
{ | ||
|
||
miSendNote.i = token; | ||
var json_in = JsonSerializer.Serialize(miSendNote); | ||
Console.WriteLine(json_in); | ||
|
||
var content = new StringContent(json_in, Encoding.UTF8, @"application/json"); | ||
|
||
Console.WriteLine("API Call..."); | ||
|
||
var responce = await client.PostAsync(_url + "/notes/create", content); | ||
|
||
Console.WriteLine(responce.StatusCode); | ||
|
||
var responce_text = await responce.Content.ReadAsStringAsync(); | ||
Console.WriteLine(responce_text); | ||
return responce_text; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MisskeyDotNet.WebAPI; | ||
|
||
public class MiSendNote | ||
{ | ||
public string i { get; set;} | ||
public string visibility { get; set; } = "public"; | ||
public List<string> visibleUserIds { get; set; } = new(); | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string cw { get; set; } = null; | ||
public bool localOnly { get; set; } = false; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public object reactionAcceptance { get; set; } = null; | ||
public bool noExtractMentions { get; set; } = false; | ||
public bool noExtractHashtags { get; set; } = false; | ||
public bool noExtractEmojis { get; set; } = false; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string replyId { get; set; } = null; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public object renoteId { get; set; } = null; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string channelId { get; set; } = null!; | ||
public string text { get; set; } = ""; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public object fileIds { get; set; } = null; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public object mediaIds { get; set; } = null; | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public object poll { get; set; } = null; | ||
} |