/// <summary> /// 指定したユーザーのフォローを解除します。 /// </summary> /// <param name="userId">ユーザー ID</param> public async Task DeleteAsync(long userId) { Ensure.GreaterThanZero(userId, nameof(userId)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("user_id", userId.ToString()) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/user/follow/delete", parameters); }
/// <summary> /// 指定したイラスト ID を閲覧履歴へと追加します。 /// </summary> /// <param name="illustIds">イラスト ID</param> public async Task AddAsync(long[] illustIds) { Ensure.ArraySizeNotZero(illustIds, nameof(illustIds)); var parameters = new List <KeyValuePair <string, string> >(); parameters.AddRange(parameters.Select(w => new KeyValuePair <string, string>("illust_ids[]", w.ToString()))); await PixivClient.PostAsync("https://app-api.pixiv.net/v2/user/browsing-history/illust/add", parameters).Stay(); }
/// <summary> /// 指定したタグのミュートを解除します。 /// </summary> /// <param name="tags">タグ名</param> public async Task DeleteAsync(string[] tags) { Ensure.ArraySizeNotZero(tags, nameof(tags)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("delete_tags[]", string.Join(",", tags)) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/mute/edit", parameters).Stay(); }
/// <summary> /// 指定したユーザーをフォローします。 /// </summary> /// <param name="userId">ユーザー ID</param> /// <param name="restrict">公開制限</param> public async Task AddAsync(long userId, Restrict restrict = Restrict.Public) { Ensure.GreaterThanZero(userId, nameof(userId)); Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict)); Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("user_id", userId.ToString()), new KeyValuePair <string, string>("restrict", restrict.ToParameter()) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/user/follow/add", parameters); }
/// <summary> /// 指定したイラストをブックマークに追加します。 /// </summary> /// <param name="illustId">イラスト ID</param> /// <param name="restrict">公開制限</param> /// <param name="tags">タグ</param> public async Task AddAsync(long illustId, Restrict restrict = Restrict.Public, string[] tags = null) { Ensure.GreaterThanZero(illustId, nameof(illustId)); Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict)); Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("illust_id", illustId.ToString()), new KeyValuePair <string, string>("restrict", restrict.ToParameter()) }; if (tags?.Length > 0) { parameters.Add(new KeyValuePair <string, string>("tags[]", string.Join(",", tags))); } await PixivClient.PostAsync("https://app-api.pixiv.net/v2/illust/bookmark/add", parameters).Stay(); }
/// <summary> /// 作業環境を更新します。 /// </summary> /// <param name="printer">プリンター</param> /// <param name="desk">机</param> /// <param name="scanner">スキャナー</param> /// <param name="monitor">モニター</param> /// <param name="tool">ソフト</param> /// <param name="desktop">机の上にあるもの</param> /// <param name="tablet">タブレット</param> /// <param name="music">絵を描く時に聞く音楽</param> /// <param name="chair">椅子</param> /// <param name="comment">その他</param> /// <param name="pc">コンピュータ</param> /// <param name="mouse">マウス</param> public async Task EditAsync(string printer = "", string desk = "", string scanner = "", string monitor = "", string tool = "", string desktop = "", string tablet = "", string music = "", string chair = "", string comment = "", string pc = "", string mouse = "") { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("printer", printer), new KeyValuePair <string, string>("desk", desk), new KeyValuePair <string, string>("scanner", scanner), new KeyValuePair <string, string>("monitor", monitor), new KeyValuePair <string, string>("tool", tool), new KeyValuePair <string, string>("desktop", desktop), new KeyValuePair <string, string>("tablet", tablet), new KeyValuePair <string, string>("music", music), new KeyValuePair <string, string>("chair", chair), new KeyValuePair <string, string>("comment", comment), new KeyValuePair <string, string>("pc", pc), new KeyValuePair <string, string>("mouse", mouse) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/user/workspace/edit", parameters); }
/// <summary> /// リフレッシュトークンを使用して、アクセストークンを更新します。 /// ログインアラートを発生させたくない場合は、前回取得した <see cref="Tokens" /> から、 <see cref="Tokens.DeviceToken" /> を指定する必要があります。 /// </summary> /// <param name="refreshToken"> /// <see cref="Tokens.RefreshToken" /> /// </param> /// <param name="deviceToken">デバイス固有トークン</param> /// <returns>更新されたログイン情報</returns> public async Task <Tokens> RefreshAsync(string refreshToken, string deviceToken = "pixiv") { Ensure.NotNullOrWhitespace(refreshToken, nameof(refreshToken)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("refresh_token", refreshToken), new KeyValuePair <string, string>("client_id", PixivClient.ClientId), new KeyValuePair <string, string>("client_secret", PixivClient.ClientSecret), new KeyValuePair <string, string>("get_secure_url", "true"), new KeyValuePair <string, string>("device_token", deviceToken), new KeyValuePair <string, string>("grant_type", "refresh_token") }; var response = await PixivClient.PostAsync("https://oauth.secure.pixiv.net/auth/token", parameters, false).Stay(); var tokens = response["response"].ToObject <Tokens>(); PixivClient.AccessToken = tokens.AccessToken; PixivClient.RefreshToken = tokens.RefreshToken; return(tokens); }