Find Jobs
Hire Freelancers

Translate a PHP function to Delphi

$30-100 USD

Cerrado
Publicado hace más de 17 años

$30-100 USD

Pagado a la entrega
I need the following PHP/CURL function translated into a Delphi/WinInet function. I'll pay $30 only. This should be a ten minute job for any one familier with Delphi and Windows API. Microsoft provides good documentation here: [login to view URL] Here's the working PHP/CURL function: ===================================== function SSLPost($url, $postData){ $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt ($ch, CURLOPT_TIMEOUT, 20); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec($ch); curl_close($ch); } Here's what I've got so far in Delphi/WinInet (not working): ============================================================ function SSLPost(url, postData: string): string; var hSession, hConnect, hRequest: HInternet; Buffer: Array[0..Pred(1024)] of Byte; BufferLength: DWORD; stream: TStringStream; AcceptType: LPStr; domain, path, header: string; begin header:= 'Content-Type: application/x-www-form-urlencoded'; AcceptType := PChar('*/*'); stream:= [login to view URL](''); try hSession := InternetOpen('Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)', PRE_CONFIG_INTERNET_ACCESS, nil,nil,0); if assigned(hSession) then try hConnect:= InternetConnect(hSession,PChar(domain),443,nil,nil,INTERNET_SERVICE_HTTP,0,0); if assigned(hConnect) then try hRequest:= HttpOpenRequest(hConnect,'POST',PChar(path),nil,nil,@AcceptType,INTERNET_FLAG_RELOAD,0); HttpSendRequest(hRequest, pchar(header), length(header), pchar(postData), length(postData)); if assigned(hRequest) then try if (extractHeaderCode(hRequest)=200) then begin repeat InternetReadFile(hRequest, @Buffer, 1024, BufferLength); [login to view URL](Buffer, BufferLength); until BufferLength = 0; Result:= [login to view URL]; end; finally InternetCloseHandle(hRequest); end finally InternetCloseHandle(hConnect); end; finally InternetCloseHandle(hSession); end; finally [login to view URL]; end; end; TEST CASE: ========== Here is the test case: (note: you'll have to replace [username] and [pass] with a real Google Adsense account login) The returned result should be a comma-delimited table. If you get the login page back then the function is not following the login or cookies are not being delt with correctly. url: [login to view URL] pageData: destination=/adsense/report/aggregate?sortColumn=0&reverseSort=false&outputFormat=TSV_EXCEL&product=afc&dateRange.simpleDate=today&dateRange.dateRangeType=custom&dateRange.customDate.start.day=23&dateRange.customDate.start.month=8&dateRange.customDate.start.year=2006&dateRange.customDate.end.day=22&dateRange.customDate.end.month=9&dateRange.customDate.end.year=2006&unitPref=page&reportType=property&searchField=&groupByPref=date&username=[username]&password=[pass]&null=Login That's it, I just need one procedure translated and I'm halfway there already.
ID del proyecto: 93975

Información sobre el proyecto

3 propuestas
Proyecto remoto
Activo hace 17 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos

Sobre este cliente

Bandera de UNITED STATES
Granite bay, United States
0,0
0
Miembro desde jul 16, 2004

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.