Zloy_Gelud

Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору [LH Module] WinHttp v1.1 Цитата: About WinHTTP Microsoft Windows HTTP Services (WinHTTP) provides developers with a server-supported, high-level interface to the HTTP/1.1 Internet protocol. WinHTTP is designed to be used primarily in server-based scenarios by server applications that communicate with HTTP servers. | Скачать ~24.7 kB Пример использования модуля для авторизации на официальном форуме сабжа: Код: -- Alias local md5 = Crypto.MD5DigestFromString; -- User data local sUsername = ""; local sPassword = ""; -- Post data local sPostData = 'vb_login_username='..sUsername..'&vb_login_password_hint='..sUsername..'&vb_login_password=&cookieuser=1&s=&securitytoken=guest&do=login&vb_login_md5password='..md5(sPassword)..'&vb_login_md5password_utf='..md5(sPassword); -- Initialize and get session handle local hOpen = WinHttp.Open(); if (hOpen ~= -1) then -- Get connection handle local hConnect = WinHttp.Connect(hOpen, 'www.indigorose.com'); if (hConnect ~= -1) then -- Make a request local hRequest = WinHttp.OpenRequest(hConnect, "POST", 'forums/login.php?do=login'); if (hRequest ~= -1) then -- Add header fields to the request WinHttp.AddRequestHeaders(hRequest, "Host: www.indigorose.com"); WinHttp.AddRequestHeaders(hRequest, "Content-Type: application/x-www-form-urlencoded"); WinHttp.AddRequestHeaders(hRequest, "Connection: keep-alive"); WinHttp.AddRequestHeaders(hRequest, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); WinHttp.AddRequestHeaders(hRequest, "Accept-Encoding: gzip, deflate"); WinHttp.AddRequestHeaders(hRequest, "Accept-Language: en-US,en;q=0.5"); WinHttp.AddRequestHeaders(hRequest, "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0"); WinHttp.AddRequestHeaders(hRequest, "Content-Length: "..sPostData:len()); -- Send it if WinHttp.SendRequest(hRequest, nil, sPostData) then -- Wait for the response if WinHttp.ReceiveResponse(hRequest) then -- Check if there is a response if WinHttp.QueryDataAvailable(hRequest) then -- Get full header local sHeader = WinHttp.QueryHeaders(hRequest); -- Display retrieved header Dialog.Message("Headers", sHeader, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end end end WinHttp.CloseHandle(hRequest); end WinHttp.CloseHandle(hConnect); end WinHttp.CloseHandle(hOpen); end | Новые действие будут добавлены позже.. | Всего записей: 3281 | Зарегистр. 30-05-2007 | Отправлено: 00:24 06-01-2014 | Исправлено: Zloy_Gelud, 00:26 06-01-2014 |
|