[질문] libcurl을 사용해서 파란에 로긴을 하고 싶습니다.. 소스좀 봐주세요~~
글쓴이: zoomout150 / 작성시간: 목, 2008/11/27 - 7:45오후
안녕하세요~~
답답한 마음에 글을 올립니다.
파란에서 공짜로 제공하는 SMS 서비스로 로긴하여 SMS를 날리려고 하거든요..
그런데 첫 단계인 로긴하는 부분부터 막히네요 ㅡㅜ
쿠키가 만들어 지지도 않고... 로긴도 안되고... 접속해서 데이터를 받다가 뻣는것 같습니다.
제가 워낙 네트웍 지식이 빈약해서 해결할 실마리가 안보이네요 ㅡㅜ
도와주세요~~~~
더불어서 도움이 될만한 책이 있다면 추천 부탁드립니다 ^^;
int main(int argc, char** argv) { const char* strTargetUrl = "http://main.paran.com/mainAction.do?method=paranMainLogin"; const char* strPostFilds = "http%3A%2F%2Fmailsms.paran.com&wbSurl=http%3A%2F%2Fmailsms.paran.com&wbUserid=아이디&wbDomain=paran.com&wbPasswd=비밀번호&wbSecure=1&x=49&y=10"; const char* strReferer = "http://mailsms.paran.com/"; curl_global_init( CURL_GLOBAL_ALL ) ; CURL* ctx = curl_easy_init() ; if( NULL == ctx ){ std::cerr << "Unable to initialize cURL interface" << std::endl ; return( ERROR_CURL_INIT ) ; } curl_easy_setopt(ctx, CURLOPT_HEADER, 1); curl_easy_setopt(ctx, CURLOPT_POST, 1); curl_easy_setopt(ctx, CURLOPT_POSTFIELDS, strPostFilds); curl_easy_setopt(ctx, CURLOPT_REFERER, strReferer) ; curl_easy_setopt(ctx, CURLOPT_TIMEOUT, 100); curl_easy_setopt(ctx, CURLOPT_COOKIEJAR, "D:\\"); curl_easy_setopt(ctx, CURLOPT_COOKIEFILE, "D:\\XXX.txt"); curl_easy_setopt(ctx , CURLOPT_WRITEDATA , stdout); curl_easy_setopt(ctx, CURLOPT_URL, strTargetUrl); curl_slist* responseHeaders = NULL ; responseHeaders = curl_slist_append( responseHeaders , "User-Agent: Mozilla" ) ; curl_easy_setopt(ctx , CURLOPT_HTTPHEADER , responseHeaders) ; curl_easy_setopt(ctx, CURLOPT_VERBOSE, 1); std::cout << "- - - BEGIN: response - - -" << std::endl ; CURLcode rc = curl_easy_perform(ctx) ; std::cout << "- - - END: response - - -" << std::endl ; if( CURLE_OK != rc ){ std::cerr << "Error from cURL: " << curl_easy_strerror( rc ) << std::endl ; } curl_easy_cleanup(ctx) ; curl_global_cleanup() ; std::exit( 0 ) ; return 0; }
Forums:
헉!
페이지가 이상해졌네요 ...
인클루드한 파일 부분이 빠진것 같아서 편집하려고 하는데 인클루드는 한번만 해야 한다는 에러가...
ㅎㄷㄷ..
인클루드 파일은 컴파일 되기 위한 기본파일들만 했구요.
윈도우에서 VS 2003/2008로 해봤습니다.
쿠키파일도 생성이 안되네요 ㅠㅠ
제발 도와주세요~~~
일단 strPostFilds 이
일단 strPostFilds 이 틀린거 같은데요?
그런가요??
Post로 보내는 필드가 잘못된건가요??
나름대로 패킷 캡쳐한 대로 넣었다고 생각을 했는데...
확인해보니 캡쳐한 내용과 완전히 동일합니다 ㅡㅜ
다만 차이점은 쿠키부분인데...
쿠키가 생성되지 않네요 ㅠㅠ
코드를 올리실때는 < c o d e > < / c o d e > 블럭 안에 넣어주세요 - 스페이스는 빼고 입력하세요
코드를 올리실때는 < c o d e > < / c o d e > 블럭 안에 넣어주세요 - 스페이스는 빼고 입력하세요
---------------------------------------------------------------------------------------------------------
이 댓글(comment)의 수정 및 삭제를 위해 이 글에 답글(reply)를 달지말고 원 글에 댓글(comment)로 달아주세요
-------------------------------------------------------------------------------
이 댓글(comment)의 수정 및 삭제를 위해 이 글에 답글(reply)을 쓰지 말아 주십시요.
의견이 있으시면 원 글에 댓글(comment)로 써 주세요.
댓글 달기