wanderlei Posted May 6, 2016 Report Share Posted May 6, 2016 Bom dia Pessoal, Preciso desenvolver uma função para recarga de celular usando o https via post, porem não tenho ideia de como passar os parâmetros. Peguei um exemplo muito antigo, mas não funciona ele retorna que os parâmetros não foram enviados via POST. ******************************************************************************** *** Programa..: RECARGA.PRG *** *** Data......: 05/05/2016 *** *** Módulo....: Recarga de celular - cellcard *** *** Autor.....: Wanderlei Cardoso de Oliveira *** ******************************************************************************** #include "directry.ch" #include "Fileio.ch" #include "tip.ch" **************************************************************************** FUNCTION Consulta_Produto_Recarga() **************************************************************************** * * envia o arquivo xml via https * Parametros: arquivo xml a ser enviado * **************************************************************************** LOCAL cXML := Montaxml(), oHttp try oHttp = CreateObject( "MSXML2.ServerXMLHTTP.5.0") catch Msginfo("Erro na criação do objeto MSXML2.XMLHTTP : " + Ole2TxtError()) return NIL end oHttp:open("POST", "https://www.cellcard.com.br/teste/integracao_xml.php", .F.) oHttp:SetRequestHeader("Content-Type", "text/xml; charset=utf-8" ) oHttp:send( cXML ) oHttp:WaitForResponse( 5000 ) Msginfo( oHttp:responseText,'Resposta' ) RETURN( oHttp:responseText ) ******************************************************************************** FUNCTION Montaxml() ******************************************************************************** local oXml, oTag local Timestamp := STRTRAN(DTOC(date()),"/","") + STRTRAN(LEFT(time(),5),":","") local codcompra := "" , codprod := "" , cvalor := "" , cddd := "" local cfone := "" , codret := "" , dtconsul := "" , codonline := "" oXml := TXmlDoc():New() oTag := TXmlTag():New( oXml, 'cellcard' ) oTag:addTag( 'versao', '3.94' ) oTag:addTag( 'codigo_transacao', '1' ) oTag:addTag( 'loja_primaria', 'teste' ) oTag:addTag( 'nome_primario', 'teste' ) oTag:addTag( 'senha_primaria', 'teste' ) /* oTag:addTag( 'compra', '' ) oTag:addTag( 'produto', '' ) oTag:addTag( 'valor', '' ) oTag:addTag( 'ddd', '' ) oTag:addTag( 'fone', '' ) oTag:addTag( 'id_terminal', '000001' ) oTag:addTag( 'uf_terminal', 'GO' ) oTag:addTag( 'dataHoraOperacao', '1' ) oTag:addTag( 'versao', '3.94' ) oTag:addTag( 'cod_retorno', '' ) oTag:addTag( 'dataConsulta', dtos(Date()) ) oTag:addTag( 'cod_online', '' ) */ *---> Salva o arquivo XML no disco <---* cTexto := oXml:SaveFile() ferase("Cellcard.XML") handle := fcreate("Cellcard.XML") fwrite(handle,cTexto) fClose(handle) RETURN( cTexto ) os parâmetros: codigo_transacao integer 1 loja_primaria String Login da loja nome_primario string Login do usuário senha_primaria String Senha do usuário versao Decimal 3.94 Integracao XML 395.pdf Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 6, 2016 Report Share Posted May 6, 2016 Try oConecta := CreateObject( 'Msxml2.XMLHTTP.3.0' ) Catch Try oConecta := CreateObject( 'MSXML2.XMLHTTP' ) Catch oConecta := CreateObject( 'Microsoft.XMLHTTP' ) End End oConecta:Open( 'POST', "https://www.cellcard...gracao_xml.php", .F. ) If oConecta:readyState = 1 oConecta:setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ) oConecta:Send("codigo_transacao=1"+; "&loja_primaria=teste"+; "&nome_primario=teste"+; "&senha_primaria=teste"+; "&id_terminal=001"+; "&uf_terminal=RJ"+; "&versao=3.94" ) If Empty( oConecta:ResponseBody ) MsgInfo("Sem resposta") EndIf EndIf Quote Link to comment Share on other sites More sharing options...
marcioe Posted May 6, 2016 Report Share Posted May 6, 2016 o pessoal desta empresa http://www.rcasistemas.com.br/index.php fazem esse tipo de rotinha no sistema deles, quem sabe alguem pode ajudar voce e eles usam fivewin Quote Link to comment Share on other sites More sharing options...
wanderlei Posted May 6, 2016 Author Report Share Posted May 6, 2016 Valeu Samir, vou testar. Quote Link to comment Share on other sites More sharing options...
sambomb Posted May 6, 2016 Report Share Posted May 6, 2016 o pessoal desta empresa http://www.rcasistemas.com.br/index.php fazem esse tipo de rotinha no sistema deles, quem sabe alguem pode ajudar voce e eles usam fivewin Serve eu? kapiaba 1 Quote Link to comment Share on other sites More sharing options...
wanderlei Posted May 6, 2016 Author Report Share Posted May 6, 2016 Deu certo Samir, Obrigado. Quote Link to comment Share on other sites More sharing options...
marcioe Posted May 6, 2016 Report Share Posted May 6, 2016 Serve sim amigo, SamirAbreu. Tinha esquecido o nome.. KKKk to ficando velho..... kkkkk Valeu pela ajuda ao nosso amigo..... Um dia Iluminado e produtivo para Todos... Quote Link to comment Share on other sites More sharing options...
toya Posted May 6, 2016 Report Share Posted May 6, 2016 Samir := Mestre Help 1... sambomb 1 Quote Link to comment Share on other sites More sharing options...
Theotokos Posted May 7, 2016 Report Share Posted May 7, 2016 Deu certo Samir, Obrigado. Compartilhar ai!!!! Como ficou ? Quote Link to comment Share on other sites More sharing options...
wanderlei Posted May 9, 2016 Author Report Share Posted May 9, 2016 Eu ainda não desenvolvi a integração, apenas testei a comunicação que o Samir disponibilizou, mas assim que concluir a função vou disponibiliza-la aqui. Theotokos 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.