private static async ValueTask FetchReactions(Misskey mi) { var note = await mi.ApiAsync <Note>("notes/show", new { noteId = "7zzafqsm9a", }); Console.WriteLine("Note ID: " + note.Id); Console.WriteLine("Note Created At: " + note.CreatedAt); Console.WriteLine("CW: " + note.Cw ?? "null"); Console.WriteLine("Body: " + note.Text ?? "null"); Console.WriteLine("Reactions: "); int c = 0; foreach (var kv in note.Reactions) { Console.Write(" {0}: {1}", kv.Key, kv.Value); c++; if (c == 5) { c = 0; Console.WriteLine(); } } }
static async Task Main() { Misskey io; if (File.Exists("credential")) { io = Misskey.Import(await File.ReadAllTextAsync("credential")); } else { var miAuth = new MiAuth("misskey.io", "Misskey.NET", null, null, Permission.All); if (!miAuth.TryOpenBrowser()) { Console.WriteLine("次のURLをお使いのウェブブラウザーで開き、認証を完了させてください。"); Console.WriteLine(miAuth.Url); } Console.WriteLine("認可が完了したら、ENTER キーを押してください。"); Console.ReadLine(); io = await miAuth.CheckAsync(); await File.WriteAllTextAsync("credential", io.Export()); } // await FetchReactions(io); // await SummonError(io); // await GetMeta(io); await FetchInstances(); }
static async System.Threading.Tasks.Task Main(string[] args) { Misskey misskey = new Misskey("yuzulia.xyz", "hogehoge"); Console.WriteLine("MisskeyCS misskey.address = " + misskey.getAddress()); Console.WriteLine("MisskeyCS misskey.apiToken = " + misskey.ApiToken); await misskey.API("meta"); }
private static async ValueTask FetchInstances() { var res = await Misskey.JoinMisskeyInstancesApiAsync(); Console.WriteLine($"最終更新: {res.Date}"); Console.WriteLine($"インスタンス数: {res.Stats.InstancesCount}"); Console.WriteLine($"インスタンス一覧:"); res.InstancesInfos.Select(meta => " " + meta.Url).ToList().ForEach(Console.WriteLine); }
private static async ValueTask SummonError(Misskey mi) { try { var note = await mi.ApiAsync <Note>("notes/show", new { noteId = "m", }); } catch (MisskeyApiException e) { Console.WriteLine(e.Error.Message); } }
/// <summary> /// 新しいインスタンスを生成します /// </summary> /// <param name="misskey">対象となる Misskeyオブジェクト</param> /// <param name="method">リクエストメソッド</param> /// <param name="endPoint">リクエストのエンドポイント</param> /// <param name="parameters">リクエストのパラメータ</param> /// <param name="images">イメージデータ</param> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> public MisskeyRequest( Misskey misskey, MethodType method, string endPoint, Dictionary <string, string> parameters = null, List <Image> images = null) { if (method != MethodType.GET && method != MethodType.POST) { throw new ArgumentException("method が無効です。"); } if (string.IsNullOrEmpty(endPoint) || string.IsNullOrWhiteSpace(endPoint)) { throw new ArgumentException("endPoint を空にすることは出来ません。"); } var match = Regex.Match(endPoint, "^/?([a-z0-9./-]+)/?$", RegexOptions.IgnoreCase); if (!match.Success) { throw new ArgumentException("endPoint は相対パスの形式で入力してください。"); } if (misskey == null || misskey.AppKey == null) { throw new ArgumentNullException("misskey.AppKey"); } this.Method = method; this.Parameters = parameters ?? new Dictionary <string, string>(); this.Images = images ?? new List <Image>(); // url this.BaseUrl = misskey.BaseUrl ?? new Uri("https://api.misskey.xyz/"); endPoint = match.Groups[1].ToString(); this.Url = BaseUrl + endPoint; // headers var headers = new Dictionary <string, string>(); headers.Add("sauth-app-key", misskey.AppKey); if (misskey.UserKey != null) { headers.Add("sauth-user-key", misskey.UserKey); } this.Headers = headers; }
/// <summary> /// 新しいインスタンスを生成します /// </summary> /// <param name="misskey">対象となる Misskeyオブジェクト</param> /// <param name="method">リクエストメソッド</param> /// <param name="endPoint">リクエストのエンドポイント</param> /// <param name="parameters">リクエストのパラメータ</param> /// <param name="images">イメージデータ</param> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> public MisskeyRequest( Misskey misskey, MethodType method, string endPoint, Dictionary<string, string> parameters = null, List<Image> images = null) { if (method != MethodType.GET && method != MethodType.POST) throw new ArgumentException("method が無効です。"); if (string.IsNullOrEmpty(endPoint) || string.IsNullOrWhiteSpace(endPoint)) throw new ArgumentException("endPoint を空にすることは出来ません。"); var match = Regex.Match(endPoint, "^/?([a-z0-9./-]+)/?$", RegexOptions.IgnoreCase); if (!match.Success) throw new ArgumentException("endPoint は相対パスの形式で入力してください。"); if (misskey == null || misskey.AppKey == null) throw new ArgumentNullException("misskey.AppKey"); this.Method = method; this.Parameters = parameters ?? new Dictionary<string, string>(); this.Images = images ?? new List<Image>(); // url this.BaseUrl = misskey.BaseUrl ?? new Uri("https://api.misskey.xyz/"); endPoint = match.Groups[1].ToString(); this.Url = BaseUrl + endPoint; // headers var headers = new Dictionary<string, string>(); headers.Add("sauth-app-key", misskey.AppKey); if (misskey.UserKey != null) headers.Add("sauth-user-key", misskey.UserKey); this.Headers = headers; }
private static async ValueTask GetMeta(Misskey mi) { try { var meta = await mi.ApiAsync <Meta>("meta"); Console.WriteLine($"インスタンス名: {meta.Name}"); Console.WriteLine($"バージョン: {meta.Version}"); Console.WriteLine($"説明: {meta.Description}"); Console.WriteLine($"管理者: {meta.MaintainerName}"); Console.WriteLine($"管理者メール: {meta.MaintainerEmail}"); Console.WriteLine($"LTL: {(meta.DisableLocalTimeline ? "いいえ" : "はい")}"); Console.WriteLine($"GTL: {(meta.DisableGlobalTimeline ? "いいえ" : "はい")}"); Console.WriteLine($"登録可能: {(meta.DisableRegistration ? "いいえ" : "はい")}"); Console.WriteLine($"メール: {(meta.EnableEmail ? "はい" : "いいえ")}"); Console.WriteLine($"Twitter認証: {(meta.EnableTwitterIntegration ? "はい" : "いいえ")}"); Console.WriteLine($"Discord認証: {(meta.EnableDiscordIntegration ? "はい" : "いいえ")}"); Console.WriteLine($"GitHub認証: {(meta.EnableGithubIntegration ? "はい" : "いいえ")}"); } catch (MisskeyApiException e) { Console.WriteLine(e.Error.Message); } }
public StatusStorage(Misskey account) { Items = new List <MSharp.Entity.Status>(); Account = account; }
public AuthForm() { InitializeComponent(); this._Temp = new Misskey("hmsk.eLHQBZXJmdKMqdzTbzdnIDsaifKcOIxj", new Uri("http://api.misskey.xyz")); }