|
网站菜单
|
日记 - DCMS CHECKIN
char postData[512]; sprintf(postData, "nick=%s&password=%s&aut_save=1", USERNAME, PASSWORD); WinHttpAddRequestHeaders( hLogin, L"Content-Type: application/x-www-form-urlencoded ", -1, WINHTTP_ADDREQ_FLAG_ADD ); BOOL bResults = WinHttpSendRequest( hLogin, WINHTTP_NO_ADDITIONAL_HEADERS, 0, postData, strlen(postData), strlen(postData), 0 ); if (!bResults) { printf("Login send failed "); return 1; } WinHttpReceiveResponse(hLogin, NULL); ReadResponse(hLogin); printf("Login Response: %s ", response); if (!ExtractToken()) { printf("Token extract failed "); return 1; } printf("Token extracted. "); WinHttpCloseHandle(hLogin); HINTERNET hCheckin = WinHttpOpenRequest( hConnect, L"GET", CHECKIN_PATH, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE ); WinHttpSetOption(hCheckin, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags)); // 写入 Cookie wchar_t cookieHeader[4096]; swprintf(cookieHeader, 4096, L"Cookie: auth_token=%S ", token); WinHttpAddRequestHeaders( hCheckin, cookieHeader, -1, WINHTTP_ADDREQ_FLAG_ADD ); WinHttpAddRequestHeaders( hCheckin, L"Referer: https://dcms.netlib.re/user/info.php ", -1, WINHTTP_ADDREQ_FLAG_ADD ); printf("Sending checkin request... "); bResults = WinHttpSendRequest( hCheckin, WINHTTP_NO_ADDITIONAL_HEADERS, 0, NULL, 0, 0, 0 ); if (!bResults) { printf("Checkin send failed "); return 1; } WinHttpReceiveResponse(hCheckin, NULL); ReadResponse(hCheckin); ShowResult(); printf(" Program finished. "); WinHttpCloseHandle(hCheckin); WinHttpCloseHandle(hConnect); WinHttpCloseHandle(hSession); return 0; } 评论: (3) |