Jump to content
Fivewin Brasil

infosys2

Membros
  • Posts

    78
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by infosys2

  1. Estou tentando fazer um post na API BLING e gostaria da ajuda dos colegas. Fazendo experiências primeiro com CURL.EXE mandando um post de cadastro na api conforme segue:. E estou recebendo este retorno de erro no xml: {"retorno":{"erros":[[{"erro":{"cod":6,"msg":"Start tag expected, '&#60;' not found\n"}}]]}} Alguem poderia dar uma forca para mim. NO final de tudo quero montar uma funcao em arbur para fazer esta interacao. curl -X POST "https://bling.com.br/Api/v2/deposito/json/" -d "apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13" -d "xml=dep001.xml" <?xml version="1.0" encoding="UTF-8"?> <depositos> <deposito> <descricao>Depósito Padrão</descricao <situacao>A</situacao> <depositoPadrao>true</depositoPadrao> <desconsiderarSaldo>false</desconsiderarSaldo> </deposito> </depositos> Estou
  2. function Main() LOCAL hCurl LOCAL cRetu := "" , hJson := [=>] , cHdados := [=>] curl_global_init() IF !empty( hCurl := curl_easy_init() ) curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, {"Content-Type:application/json","X-Cosmos-Token:yIgeHB34Qv6RO18QWsftQw"} ) curl_easy_setopt( hCurl, 2 , "https://bling.com.br/Api/v2/produtos/json/?apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13") curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. ) curl_easy_setopt( hCurl, HB_CURLOPT_TRANSFERTEXT, .T. ) curl_easy_setopt( hCurl, HB_CURLOPT_FAILONERROR, .T. ) curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP ) curl_easy_perform( hCurl ) cRetu := curl_easy_dl_buff_get( hCurl ) curl_easy_reset( hCurl ) ? cRetu ENDIF curl_global_cleanup() RETURN cRetu Funciona normal no windows 10 64 bits, resolvi fazendo com o curl
  3. Gostaria de saber dos colegas se vocês tem alguma solução para consumir API em ambiente de windows 7. #Include "FiveWin.ch" function Main() Local oHttp, cResp1 := "" , hJson := hash() cUrl := "https://bling.com.br/Api/v2/produtos/json/?apikey=81672077cde47c5ed795349ae17a98c1c1b10c9826041ecf9b9d28d9a1961c7204dc3b13" Try oHttp := CreateObject("winhttp.winhttprequest.5.1") catch oError Try oHttp := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' ) oHttp:SetTimeouts(40000,40000,40000,40000) Catch oError ? "Erro na comunicação" return .F. end end Try oHttp:SetTimeouts(40000,40000,40000,40000) oHttp:Open("GET",cUrl ,.f.) // erro en el site oHttp:Send() cResp1 := oHttp:ResponseText() Catch MsgAlert("002 - Erro na comunicação","Aviso") return .t. End Try hb_jsondecode( cResp1 ,@hJson) //Parse JSON to hash cHdados:= hJson["retorno"]["produtos"][1]["produto"] ? padr("Ide ",20," ")+cHdados["id"] , padr("Codigo",20," ")+cHdados["codigo"] , padr("Descricao",20," ")+cHdados["descricao"] , padr("Unidade",20," ")+cHdados["unidade"] , Padr("Preco",20," ")+cHdados["preco"] , Padr("Peso Liquido",20," ")+cHdados["pesoLiq"] Return nil Este código no windows 10 esta funcionalidade 100% ja no windows 7 não funciona!
  4. Vou pega este sistema e fazer um teste aqui pra ver se vai funcionar...
  5. Vou procurar um e-mail de teste que uso aqui depois mando pra vc.... mas em todos os e-mail que teste não funcionou o interessante que antes funcionava.... Testa ai com o seu mesmo para você ver se ainda funciona?
  6. Bom dia! Gostaria de saber se tem alguem enviando email com esta dll ACBrMail32.dll e se estar conseguindo enviar? Estava tentando enviar email e nao estou conseguindo tente com varios opcoes tipo gmail, email de dominio comercial, e outros mas nao estar funcionando. At Jair
  7. eu tinha a coleção completa de todos os livros de Antonio Geraldo Vidal...
  8. <eSocial xmlns="http://www.esocial.gov.br/schema/download/solicitacao/id/v1_0_0"> <download> <ideEmpregador> <tpInsc>1</tpInsc> <nrInsc>06117473000150</nrInsc> </ideEmpregador> <solicDownloadEvtsPorId> <id>ID1061174730000002018081415303000001</id> </solicDownloadEvtsPorId> </download> </eSocial> O que muda seria o xml a ser enviado... neste caso um xml de consulta pra baixar o registro desejado. http://www.unimake.com.br/uninfe/modelos.php?p=esocial%2F02.05.00
  9. Qual o errro que dar... preciza informar o erro para gente saber o que voce esta fazendo de errado
  10. Muito fácil se voce utiliza fivewin vai na pasta samples do fivewin cologa este prg e digita o seguinte buildh meuprg que vai criar o executável. Depois vc pega o script B32.bc para ver quais as lib necessárias
  11. #include "fivewin.ch" function main() local a, aErros , hResponse, oObj, oErr, hRet := {=>} local cUrl := "https://economia.awesomeapi.com.br/last/USD-BRL" try oObj:=createobject('msxml2.xmlhttp.6.0') catch oErr try oObj:=createobject('msxml2.xmlhttp') catch oErr try oObj:=createobject('microsoft.xmlhttp') catch oErr oObj:=nil end end end if hb_isObject( oObj ) oObj:open("GET",cUrl,.f.) oObj:send() while oObj:readyState<>4; hb_idlesleep(1); end if oObj:status>=200 .or. oObj:status<=299 hb_jsonDecode(oObj:responseText,@hRet) // transforma o json em hash * xbrowse(hRet) *? cvaltostr(hRet) * msgstop(hRet:name, hRet:high) ? hRet["USDBRL"]["code"], hRet["USDBRL"]["codein"], hRet["USDBRL"]["name"], hRet["USDBRL"]["high"], hRet["USDBRL"]["low"], hRet["USDBRL"]["varBid"], hRet["USDBRL"]["pctChange"], hRet["USDBRL"]["bid"], hRet["USDBRL"]["ask"] , hRet["USDBRL"]["create_date"] else hRet:={"error"=>{"message"=>oObj:responseText,"status"=>alltrim(str(oObj:status))}} end endif return nil
  12. Por que voce nao utiliza as dll do acbr que sao gratis e melhor inclusive mais facil de uzar... eu usava flexdocs mudei pra a dll do acbr
  13. Mas você esta usando a versão bcc55 mesmo ? se você esta usando pelo prompt dos verifique as configurações de apontamento para as pasta! Seria interessante você informar o modo de compilação que você tentou fazer a compilacao!
  14. Como você consegue pegar o numero de serie do certificado digital ?
  15. Concordo realmente fica lento ou cheguei a utilizar apenas xml
  16. Simples voce criar um campo em uma taba e grava o xml neste campo.... No modo nativo eu gravo assim para grava imagem mas vai funcionar também para pdf e xml oTable:Append( "FILENAME,PHOTO", { cFile, MEMOREAD( cFile ) } ) //OR oTable:Update( "FILENAME,PHOTO", { cFile, MEMOREAD( cFile ) } ) poderia ser assim: oRs := oCn:Rowset( "tablename" ) // position the row on the member oRs:foto := MEMOREAD( <fotofilename> ) oRs:Save() ou assim: oCn:Update( <tablename>, "foto", { MEMOREAD( filename) }, "id -= 99" ) oCn:Insert( <tablename>, "name,foto", { "Mark Venken", MEMOREAD( "fotofilename" ) } )
  17. Mais ou menos isto aqui que você fazer: private cCertificado:=cLicenca:=nil ChamaVoNfeCertSign(@cCertificado,@cLicenca) // Grava os dados do certificado aqui if cademp->cnpj="99.999.888/0001-54" .and. !file("VoNfeCertSign_empresa01.Ini") WritePProString( "CONFIGURACAO", "CERTIFICADO", oNFeUtil:cCertificado, "VoNfeCertSign_empresa01.Ini" ) elseif cademp->cnpj="99.999.888/0002-64" .and. !file("VoNfeCertSign_empresa02.Ini") WritePProString( "CONFIGURACAO", "CERTIFICADO", oNFeUtil:cCertificado, "VoNfeCertSign_empresa02.Ini" ) endif // valida o xml if !oNFeUtil:ValidaXml(cDocXml) oNfeUtil:End() return( .f. ) Endif faz todos os procedimentos restantes aqui // Destroi o objeto oNfeUtil:End() //----------------------------------------------------------------------------// Function ChamaVoNfeCertSign(cCertificado,cLicenca) local narquivo:=nil if alltrim(cademp->cnpj)="99.999.888/0001-54" cCertificado := GetPvProfString( "CONFIGURACAO", "CERTIFICADO", "", "VoNfeCertSign_empresa01.Ini") cLicenca := GetPvProfString( "CONFIGURACAO", "LICENCA", "", "VoNfeCertSign_empresa01.Ini") elseif cademp->cnpj="99.999.888/0002-64" cCertificado := GetPvProfString( "CONFIGURACAO", "CERTIFICADO", "", "VoNfeCertSign_empresa02.Ini") cLicenca := GetPvProfString( "CONFIGURACAO", "LICENCA", "", "VoNfeCertSign_empresa02.Ini") endif Return .t. //----------------------------------------------------------------------------//
  18. Unimake nao tem a cidade de atibaia
  19. Eu tentei fazer desta forma mas não deu certo! #Include "Fivewin.ch" //-------------------------------- Function Main() local cUrl:= "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula" Try oHttp := CreateObject( 'MSXML2.XMLHTTP' ) Catch oHttp := CreateObject( 'Microsoft.XMLHTTP' ) End oHttp:Open( 'POST' , cUrl , .F. ) *oDoc:LoadXML( cXml ) //carga el documento a xml ohttp:SetRequestHeader( "Authorization" , "999991-2EU2TPWLJBP2H57HL605K24778989PPP" ) ohttp:SetRequestHeader( "postman-token" , "06646388:AAEr-QL8dNx2k6w7u0nEAOWld2Po" ) // envio xml oHttp:send("<consulta><inscricaoMunicipal>999991</inscricaoMunicipal><codigoVerificacao>2978937BMA</codigoVerificacao></consulta>") cRespuesta:= oHttp:responseText ? cRespuesta return nil Exemplos contido na documentação WEB SERVICE – EXEMPLOS DE EXECUÇÃO DO WEBSERVICE EM DIVERSAS LINGUAGEM DE PROGRAMAÇÃO LINGUAGEM C LibCurl CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "postman-token: 26e44762-e741-d9bc-d1e4-200f018ad85f"); headers = curl_slist_append(headers, "cache-control: no-cache"); headers = curl_slist_append(headers, "content-type: application/xml"); headers = curl_slist_append(headers, "authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, " XML A SER ENVIADO"); CURLcode ret = curl_easy_perform(hnd); cURL curl -X POST \ http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula \ -H 'authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP' \ -H 'cache-control: no-cache' \ -H 'content-type: application/xml' \ -H 'postman-token: 25a25272-851b-1763-f96f-6ac0017ad209' \ -d ' XML A SER ENVIADO' C# Sharp var client = new RestClient("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); var request = new RestRequest(Method.POST); request.AddHeader("postman-token", "f6645f63-84a0-36b8-0e37-b26a359830ae"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/xml"); request.AddHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP"); request.AddParameter("application/xml", " XML A SER ENVIADO", ParameterType.RequestBody); IRestResponse response = client.Execute(request); LINGUAGEM JAVA OK HTTP OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/xml"); RequestBody body = RequestBody.create(mediaType, " XML A SER ENVIADO"); Request request = new Request.Builder() .url("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula") .post(body) .addHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP") .addHeader("content-type", "application/xml") .addHeader("cache-control", "no-cache") .addHeader("postman-token", "dc16978a-e237-b880-24e4-3ca35eab00b3") .build(); Response response = client.newCall(request).execute(); Unirest HttpResponse<String> response = Unirest.post("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula") .header("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP") .header("content-type", "application/xml") .header("cache-control", "no-cache") .header("postman-token", "67b88492-17dd-7d35-e267-17f0aeccf5b8") .body(" XML A SER ENVIADO") .asString(); LINGUAGEM – JAVASCRIPT JQUERY var settings = { "async": true, "crossDomain": true, "url": "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula", "method": "POST", "headers": { "authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP", "content-type": "application/xml", "cache-control": "no-cache", "postman-token": "aa7b25cd-9870-4605-7e15-a25ce549cbbc" }, "data": " XML A SER ENVIADO" } $.ajax(settings).done(function (response) { console.log(response); }); XHR var data = " XML A SER ENVIADO"; var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { if (this.readyState === 4) { console.log(this.responseText); } }); xhr.open("POST", "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); xhr.setRequestHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP"); xhr.setRequestHeader("content-type", "application/xml"); xhr.setRequestHeader("cache-control", "no-cache"); xhr.setRequestHeader("postman-token", "044267bc-306d-0093-f98f-e4124b4dbc44"); xhr.send(data); LINGUAGEM – NODEJS NATIVE var http = require("http"); var options = { "method": "POST", "hostname": "webservice.giap.com.br", "port": null, "path": "/WSNfses/nfseresources/ws/v2/emissao/simula", "headers": { "authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP", "content-type": "application/xml", "cache-control": "no-cache", "postman-token": "6f3c611b-ef46-e723-82be-0bf804f35636" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write(" XML A SER ENVIADO"); req.end(); REQUEST var request = require("request"); var options = { method: 'POST', url: 'http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula', headers: { 'postman-token': '16baa6d5-7845-8a94-f6e6-881e6a98924a', 'cache-control': 'no-cache', 'content-type': 'application/xml', authorization: '999991-2EU2TPWLJBP2H57HL605K24778989PPP' }, body: ' XML A SER ENVIADO' }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); UNIREST var unirest = require("unirest"); var req = unirest("POST", "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); req.headers({ "postman-token": "07503d21-1a63-405e-d24e-84332f21cdd1", "cache-control": "no-cache", "content-type": "application/xml", "authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP" }); req.send(" XML A SER ENVIADO"); req.end(function (res) { if (res.error) throw new Error(res.error); console.log(res.body); }); LINGUAGEM – PHP HttpRequest <?php $request = new HttpRequest(); $request->setUrl('http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula'); $request->setMethod(HTTP_METH_POST); $request->setHeaders(array( 'postman-token' => 'bde5f2ea-327a-ee59-1178-2a7b68a738e1', 'cache-control' => 'no-cache', 'content-type' => 'application/xml', 'authorization' => '999991-2EU2TPWLJBP2H57HL605K24778989PPP' )); $request->setBody(' XML A SER ENVIADO'); try { $response = $request->send(); echo $response->getBody(); } catch (HttpException $ex) { echo $ex; } pecl_http <?php $client = new http\Client; $request = new http\Client\Request; $body = new http\Message\Body; $body->append(' XML A SER ENVIADO'); $request->setRequestUrl('http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders(array( 'postman-token' => '559a1ef4-fcd3-fc4c-537b-9ed6c96fda4b', 'cache-control' => 'no-cache', 'content-type' => 'application/xml', 'authorization' => '999991-2EU2TPWLJBP2H57HL605K24778989PPP' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); cURL <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => " XML A SER ENVIADO", CURLOPT_HTTPHEADER => array( "authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP", "cache-control: no-cache", "content-type: application/xml", "postman-token: 93d65476-41c5-90c3-05ae-6103573b41ba" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } LINGUAGEM – PYTHON http.client (PYTHON 3) import http.client conn = http.client.HTTPConnection("webservice.giap.com.br") payload = " XML A SER ENVIADO" headers = { 'authorization': "999991-2EU2TPWLJBP2H57HL605K24778989PPP", 'content-type': "application/xml", 'cache-control': "no-cache", 'postman-token': "f7bcfadb-78ad-925c-51f0-cafb384c3dab" } conn.request("POST", "/WSNfses/nfseresources/ws/v2/emissao/simula", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) requests import requests url = "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula" payload = " XML A SER ENVIADO" headers = { 'authorization': "999991-2EU2TPWLJBP2H57HL605K24778989PPP", 'content-type': "application/xml", 'cache-control': "no-cache", 'postman-token': "f8281546-13aa-9e25-a5fe-32b81207ac21" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text) LINGUAGEM – RUBY RUBY require 'uri' require 'net/http' url = URI("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) request["authorization"] = '999991-2EU2TPWLJBP2H57HL605K24778989PPP' request["content-type"] = 'application/xml' request["cache-control"] = 'no-cache' request["postman-token"] = 'c4f9c73a-a7ad-efe3-00a3-2d5aa19db3f8' request.body = " XML A SER ENVIADO" response = http.request(request) puts response.read_body
  20. Boa Tarde Gostaria de saber se alguém consegue me ajudar a fazer uma função para consumir o web service da prefeitura de Atibaia. Encontre alguns exemplos na documentação do web service de atibia em outras linguagens. LibCurl CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "postman-token: 26e44762-e741-d9bc-d1e4-200f018ad85f"); headers = curl_slist_append(headers, "cache-control: no-cache"); headers = curl_slist_append(headers, "content-type: application/xml"); headers = curl_slist_append(headers, "authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, " XML A SER ENVIADO"); CURLcode ret = curl_easy_perform(hnd); cURL curl -X POST \ http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula \ -H 'authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP' \ -H 'cache-control: no-cache' \ -H 'content-type: application/xml' \ -H 'postman-token: 25a25272-851b-1763-f96f-6ac0017ad209' \ -d ' XML A SER ENVIADO' C# Sharp var client = new RestClient("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula"); var request = new RestRequest(Method.POST); request.AddHeader("postman-token", "f6645f63-84a0-36b8-0e37-b26a359830ae"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/xml"); request.AddHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP"); request.AddParameter("application/xml", " XML A SER
  21. Concordo e falei isto pra ele. SE fosse home eu mesmo aceitaria o trabalho.
  22. Boa tarde! Algum colega aqui no formum precisando de trabalhar um amigo entrou em contato comigo hoje e esta precisando e um programado fivewin nao pode ser home office tem que ser na empresa horário comercial.
  23. Vou testar, acredito que vai funcionar 100% Fico muito grato por sua ajuada!
×
×
  • Create New...