In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

TipClient

Foro público de Xailer en español
Responder
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

TipClient

Mensaje por Cassiano de Oliveira »

Se utilizo a Classe TipClient do harbour conforme abaixo...

Código: Seleccionar todo

  Public cUrl := "http://www.receita.fazenda.gov.br/Aplicacoes/ATCTA/cpf/ConsultaPublica.asp"
      Public cUrlC:= "http://www.receita.fazenda.gov.br/Aplicacoes/ATCTA/cpf/captcha/gerarCaptcha.asp"
      Public cUrl1:= "http://www.receita.fazenda.gov.br/Aplicacoes/ATCTA/cpf/ConsultaPublicaExibir.asp"

Código: Seleccionar todo

      oInternet:= TIPClientHTTP():New(cURL1, .f.)
Da erro ao compilar...

Código: Seleccionar todo

A compilar: frmConsulta.prg...
A linkar: consulta.exe...
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0xc): undefined reference to `pcre_free'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0x66): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0x10c): undefined reference to `pcre_compile'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0x3a4): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0x565): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0x96c): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0xafc): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0xc6a): undefined reference to `pcre_exec'
D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o):hbregex.c:(.text+0xdcd): more undefined references to `pcre_exec' follow
D:\DEV\xailer\hb32\comp\mingw\Bin\ld: D:/DEV/xailer/hb32/Lib/Win/mingw/libhbrtl.a(hbregex.o): bad reloc address 0x4 in section `.text.startup'
1 Files, 0 Warnings, 10 Errors
Compilar tempo: 0.80s   Linkar tempo: 0.50s   Tempo total: 1.32s
Preciso utilizar o TipClient no código abaixo:

Código: Seleccionar todo

Local oUrl, oInternet, cData, cRet:= '', aRetorno, cTexto, nIni, nFim, hHeaders1, cParm

   cParm:= { { "txtTexto_captcha_serpro_gov_br", cCaptcha },;
             { "tempTxtCPF", cCpf },;
             { "tempTxtNascimento", DToC(cDataN) },;
             { "temptxtToken_captcha_serpro_gov_br", '' },;
             { "temptxtTexto_captcha_serpro_gov_br", cCaptcha }}

	hHeaders1:= HB_Hash()
	            hHeaders1["Content-Type"]:= "application/x-www-form-urlencoded"
               hHeaders1["Accept"]:= "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
     	         hHeaders1["Accept-Encoding"]:= "gzip, deflate"
     	         hHeaders1["Accept-Language"]:= "pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3"
     	         hHeaders1["Connection"]:= "keep-alive"
   Try
      oInternet:= TIPClientHTTP():New(cURL1, .f.)
   Catch
		MsgStop('Erro na Conexão','Consulta CPF')
		Return .f.
	End
   oInternet:SetCookie(cStringCookie)
   oInternet:hHeaders:= hHeaders1
	If oInternet:Open()
		If oInternet:Post(cParm)
			cRet:=oInternet:ReadAll()
      Else
      	MsgStop('Erro no Post','Consulta CPF')
      	Return .F.
		EndIf
	Else
		MsgStop('Erro na Conexão','Consulta CPF')
		Return .f.
	EndIf
	oInternet:Close()
Qual o motivo desse erro?
ftwein
Mensajes: 50
Registrado: Lun Oct 22, 2007 5:17 pm

Re: TipClient

Mensaje por ftwein »

Você tem que selecionar a hbpcre em Propriedades do Projeto / Livrarias.
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

Re: TipClient

Mensaje por Cassiano de Oliveira »

Obrigado...

Além da hbpcre também tive que adicionar libiphlpapi

Ai resolveu...

Solved

Thanks.
Responder