Esempio n. 1
0
        public void GuiTin(ThongTinTaiKhoan nguoigui, ThongTinTaiKhoan nguoinhan, string tieude, string noidung, Action <string> callback = null)
        {
            if (nguoigui.Cookie == null)
            {
                throw new Exception("Thiếu cookie");
            }
            tieude = tieude.Split('(')[0].Trim();
            bool dungTieude = false;

            for (int i = 1; i <= 10; i++)
            {
                if (tieude == string.Format("default_{0}", i))
                {
                    dungTieude = true;
                    break;
                }
            }
            if (!dungTieude)
            {
                throw new Exception("Vui lòng chọn tiêu đề như gợi ý: default_<số từ 1 đến 10>\nVí dụ: default_1");
            }

            string data     = string.Format("memberid={0}&subject={1}&body={2}&cssSuffix=sm&subjectChanged=false&replyID=0&mailsInThread=0&imbraconsent=0", nguoinhan.Id, tieude, Uri.EscapeDataString(noidung));
            var    response = RequestToWeb.POST2(new Uri("https://www.vietnamcupid.com/vi/mail/sendEmail?ajaxMode=false"), nguoigui.Cookie, data, false, false, "application/x-www-form-urlencoded; charset=UTF-8");
            var    headers  = RequestToWeb.ReadHeader(response);

            nguoinhan.TrangThai = nguoigui.TaiKhoan;
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                string stringResponse = sr.ReadToEnd();
                string noidung1       = noidung.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                if (!stringResponse.Contains(noidung1))
                {
                    nguoinhan.TrangThai = "Gửi lỗi\n(không nhận tin nhắn cùng giới hoặc đã quá giới hạn gửi)";
                }
            }
        }