VB6 -> C# 포팅, 네이버 로그인, 네이버 쪽지 전송, 네이버 메일 전송
네이버 로그인:
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; }
'소스 관련' 카테고리의 다른 글
헤더를 VB6 코드로 쉽게 변환! (HEADER -> VB6 CODE CONVERTER) (2) | 2013.01.02 |
---|---|
POST 데이터 비교(POST Data Compare) (0) | 2013.01.02 |
유용한 getImageFromURL, DownloadRemoteImageFile 함수 (4) | 2012.12.02 |
POST/GET Transmitter 프로젝트. (0) | 2012.12.02 |
프로세스 클리너 프로젝트 진행 중 개발 중단 (0) | 2012.11.23 |