Olá. Boa tarde.
Desconheço totalmente a API do ML, porém, já integrei outras.
Utilizo o comando Curl para consumir webservices, através de uma chamada bem básica: __run().
Usando Soap/XML:
cRun := 'curl -s -k -H "Content-Type: text/xml; charset=utf-8"'+;
' -H "SOAPAction: http://maximaweb.com.br/service/maximawebservice/maximaweb/' + cFuncao + '"' + ;
' -d @' + cArqEnv + ;
' -o ' + cArqRet + ;
' '+cWebService+' '
__run( cRun )
Usando JSON - GET
local cArqTemp := RetPathArqTemp( "pb.out" )
local cWebService := if( IsPlugBoletoModoTeste(), ;
'https://homologacao.plugboleto.com.br/api/v1/boletos', ;
'https://plugboleto.com.br/api/v1/boletos' )
local cHeaders := ''
local hRet
local nH
local aDados
cHeaders += ' -H "cnpj-sh:' + PlugBoletoCNPJSH() + '" '
cHeaders += ' -H "token-sh:' + PlugBoletoToken() + '" '
cHeaders += ' -H "cnpj-cedente:' + EMPRESA->CGCCPF + '" '
#ifdef __PLATFORM__LINUX
cRun := "curl -s -X GET "
#else
cRun := "C:\opt\curl-7.72.0\bin\curl.exe -s -X GET "
#endif
cRun += " -o " + cArqTemp + " "
cRun += cHeaders
cRun += " --silent "
cRun += ' "' + cWebService + '?' + 'IdIntegracao=' + cIdIntegracao + '"'
__run( cRun )
Usando JSON - POST
local cArqTemp := RetPathArqTemp( "pb.out" )
local cArqJSON := RetPathArqTemp( "pb.json" )
local cWebService := if( IsPlugBoletoModoTeste(), ;
'https://homologacao.plugboleto.com.br/api/v1/boletos/altera/lote', ;
'https://plugboleto.com.br/api/v1/boletos/altera/lote' )
local cHeaders := ''
cHeaders += ' -H "Content-Type:application/json" '
cHeaders += ' -H "cnpj-sh:' + PlugBoletoCNPJSH() + '" '
cHeaders += ' -H "token-sh:' + PlugBoletoToken() + '" '
cHeaders += ' -H "cnpj-cedente:' + EMPRESA->CGCCPF + '" '
cData := hb_jsonencode( hData )
if ( nH := fcreate( cArqJSON ) ) > 0
fwrite( nH, cData )
fclose( nH )
#ifdef __PLATFORM__LINUX
cRun := "curl -s -X POST "
#else
cRun := "C:\opt\curl-7.72.0\bin\curl.exe -s -X POST "
#endif
cRun += " -o " + cArqTemp + " "
cRun += cHeaders
cRun += " -d @" + cArqJSON + " "
cRun += " --silent "
cRun += ' "' + cWebService + '"'
__run( cRun )
endif
Espero que lhe dê um “norte” para começar. Boa sorte.
Uma alternativa mais elegante é linkar as libs Curl, SSL e etc... e fazer as chamadas, diretamente, sem __run().
Att,
Marcelo
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups
"Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/CACtBdbm6-hxqL8n8PLmGQHQR4xK8k3o1ReiFMgmZ8O3%2BuJkH5w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/CAC9CD56C14144F8BE0EC0DC12B708F8%40notemarcelo.