자동로그인
public static bool NaverLogin(string ID, string PW, CookieContainer cookie) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://nid.naver.com/nidlogin.login"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Referer = "https://nid.naver.com/nidlogin.login"; request.CookieContainer = cookie; StreamWriter swriter = new StreamWriter(request.GetRequestStream()); swriter.Write("enctp=2&svctype=0&id=" + ID + "&pw=" + PW); swriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream resStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(resStream, Encoding.Default); string result = readStream.ReadToEnd(); resStream.Close(); readStream.Close(); if (result.IndexOf("http://static.nid.naver.com/sso/cross-domain.nhn") >= 0) return true; } return false; }
네이버 쪽지 전송:
public static bool NaverMessage(string to, string body, CookieContainer cookie) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://m.note.naver.com/mobile/mobileCaptchaViewCheck.nhn?"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Referer = "http://m.note.naver.com/mobile/mobileSendNoteForm.nhn?returnUrl=http%3a%2f%2fm.note.naver.com%2fmobile%2fmobileReceiveList.nhn"; request.CookieContainer = cookie; StreamWriter swriter = new StreamWriter(request.GetRequestStream()); swriter.Write("fromUrl=%2Fmobile%2FmobileSendNoteForm.nhn%3FselfSend%3D0&returnUrl=http%3A%2F%2Fm.note.naver.com%2Fmobile%2FmobileReceiveList.nhn&svcType=0&svcId=&svcName=&svcTitle=&svcLink=¬e=" + System.Web.HttpUtility.UrlEncode(body, Encoding.Default) + "&targetId=" + to + "&isBackup=true&isReplyNote=false"); swriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream resStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(resStream, Encoding.UTF8); string result = readStream.ReadToEnd(); resStream.Close(); readStream.Close(); if (result.IndexOf("성공") >= 0) return true; } return false; }
네이버 메일 전송
public static bool NaverMail(string id, string senderName, string to, string subject, string body, CookieContainer cookie) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://mail.naver.com/json/write/send/"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Referer = "http://mail.naver.com/"; request.CookieContainer = cookie; StreamWriter swriter = new StreamWriter(request.GetRequestStream()); swriter.Write("senderName=" + senderName + "&to=" + to + "&cc=&bcc=&subject=" + subject + "&body=" + body + "&contentType=html&charset=AUTO&sendSeparately=false&saveSentBox=true&type=new&fromMe=0&attachID=tseCWrwm_LYmKoumKSevFou97qUm7riGWzwCMBKTM40nWzJCbqMZKAEwKou.&reserveDate=&reserveGMT=&reserveTime=&calendarVal=&autoSaveMailSN=&addReceiverAddress=false&attachCount=0&attachSize=0&bigfile=&sessionID=&seqNums=&priority=0&ndriveFileInfos=&lists=&serviceID=&u=" + id); swriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream resStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(resStream, Encoding.UTF8); string result = readStream.ReadToEnd(); resStream.Close(); readStream.Close(); if (result.IndexOf("성공") >= 0) return true; } return false; }< 출처 : http://blog.eairship.kr/193 >
댓글 없음:
댓글 쓰기