public MainWindow() : base(Gtk.WindowType.Toplevel) { ICookieGetter cg = CookieGetter.CreateInstance(BrowserType.Chromium); Cookie cookie = cg.GetCookie(new Uri("http://live.nicovideo.jp/"),"user_session"); _user = new NicoUser(cookie); Build (); }
public void DoNicoru(NicoUser user) { string url = "http://ru-cliapi.nicovideo.jp/1/item/nicoru"; Json.NicoruResponse json = Post(user,url); if(json.Error != null){ throw new Exception(String.Format("ニコるのに失敗しました {0} {1} {2} {3}",json.Status,json.StatusCode,json.Error.Code,json.Error.Description)); } }
Json.NicoruResponse Post(NicoUser user,string url) { string data = String.Format("items={1}&token={0}",user.Token,_nicoru); byte[] datab = Encoding.UTF8.GetBytes(data); WebRequest req = WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = datab.Length; Stream st = req.GetRequestStream(); st.Write(datab,0,data.Length); st.Close(); WebResponse res = req.GetResponse(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Json.NicoruResponse)); Stream resst = res.GetResponseStream(); return (Json.NicoruResponse)ser.ReadObject(resst); }
public Nicorepo(NicoUser user) { items = new List<INicorepoItem>(); _user = user; }
public Json.NicoruResponse Nicorare(NicoUser user) { string url = "http://ru-cliapi.nicovideo.jp/1/item/nicorare_count"; return Post(user,url); }