Integração de ERP com API do MercadoLivre

197 views
Skip to first unread message

Amauri Soares de Oliveira

unread,
Feb 4, 2021, 12:52:08 PM2/4/21
to harbou...@googlegroups.com
Boa tarde amigos,

Alguém teria um exemplo de Integração do Sistema com API do MercadoLivre ?
Vou precisar fazer essa integração, porém não sei como fazer, se algum colega
puder me dar uma luz, eu agradeço.

Amauri S Oliveira
ASO Sistemas
Harbour/Minigui Ext

Marcelo(Linha Verde Informática)

unread,
Feb 4, 2021, 4:43:01 PM2/4/21
to harbou...@googlegroups.com

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.

Amauri Soares de Oliveira

unread,
Feb 10, 2021, 5:05:59 PM2/10/21
to harbou...@googlegroups.com
Blz Marcelo, obrigado pela ajuda, vou  estudar aqui seus exemplos.

Forte abraço.

Reply all
Reply to author
Forward
0 new messages