https://xxxxxxxxxx/api/v1/clientes/
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://xxxxx/api/v1/clientes/id/1"); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "87a0-4se9-bt1a-6c1d9fe4ce2e"); $result = curl_exec ($ch); curl_close ($ch);
private string ConectAPI(string postxml) { try { HttpWebRequest wq = (HttpWebRequest)WebRequest.Create("https://xxxxx/api/vi/clientes/id/1"); wq.ContentType = "application/xml"; string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes("87a0-4se9-bt1a-6c1d9fe4ce2e")); wq.Headers[HttpRequestHeader.Authorization] = "Basic " + auth; if (postxml.Length > 0) { byte[] data = Encoding.UTF8.GetBytes(postxml); wq.ContentLength = data.Length; Stream POSTstream = wq.GetRequestStream(); POSTstream.Write(data, 0, data.Length); } HttpWebResponse wp = (HttpWebResponse)wq.GetResponse(); StreamReader rd = new StreamReader(wp.GetResponseStream(), Encoding.UTF8); return rd.ReadToEnd().ToString(); } catch (Exception ex) { return ex.Message; } }
<Clientes xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <retorno> <Cliente> <enderecos> <endereco>Rua Comendador Lucas</endereco> <numero>1234</numero> <complemento /> <referencia /> <bairro>Distrito Industrial</bairro> <cidade>Vinhedo</cidade> <estado>SP</estado> <cep>13280000</cep> </enderecos> <id_cliente>15</id_cliente> <data_cadastro>2016-05-09 00:00:00</data_cadastro> <ativo>true</ativo> <email>teste@teste.com.br</email> <tipo_pessoa>f</tipo_pessoa> <empresa /> <cnpj /> <ie /> <nome>João Maia</nome> <data_nascimento>1984-05-02</data_nascimento> <sexo>m</sexo> <cpf>12345678910</cpf> <rg>1234567890</rg> <telefone>0000000000</telefone> <celular></celular> <qtd_pedidos>2</qtd_pedidos> </Cliente> </retorno> <status_api>OK</status_api> <pagina_atual>1</pagina_atual> <total_registros>1</total_registros> <total_paginas>1</total_paginas> </Clientes>
<Clientes xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <retorno /> <status_api>Nenhum registro foi encontrado.</status_api> <pagina_atual>1</pagina_atual> <total_registros>0</total_registros> <total_paginas>0</total_paginas> </Clientes>
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add example@example.com to your trusted senders list in your email software.