0
I have a website and to enter it you need to log in, and the data are: Cpf and email. And I have an API that I need to play the variables Cpf and email to be parameters in the api, but I don’t have much knowledge in api and also just have the link to it.
I need to play this data because each user will have different data, and the api will need this data in the parameter to select and fetch data from the person registered with Cpf and email.
ex.: http://api/api/TRCKCLICODCPF=12345678901&EMAIL=fulano%40email.com
Consuming API:
function load(){
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://api/api/TRCKCLICODCPF=12345678901&EMAIL=fulano%40email.com");
xhr.addEventListener("load", function() {
var resposta = xhr.responseText;
// console.log("ola1");
var clientes = JSON.parse(resposta);
// console.log("ola2");
// console.log(clientes);
for (var i =0; i < 1; i++){
// console.log("ola3");
var clientes_1 = clientes.TRACKER[i];
AdicionaNome(clientes_1);
AdicionaCPF(clientes_1);
AdicionaProduto(clientes_1);
AdicionaCidade(clientes_1);
AdicionaCodigoProduto(clientes_1);
AdicionaCodigoCliente(clientes_1);
AdicionaStatus(clientes_1);
ActiveStatusImage(clientes_1);
ActiveOnlyPostagem(clientes_1);
adicionaClienteNaTabelaViagem(clientes_1);
ActiveQtdViagem(clientes_1);
}
});
xhr.send();
}
window.onload = load;
I changed the api link, it’s just an example
And I play this code where?
– Maria
Create the PHP file of the code, and access as you want, I recommend to access by ajax, it will return you the return of the API, it is logical that you will have to adapt it to your application. If you don’t understand the code above, here on the site and in others you have everything you need about accessing functions, Url and ajax, just search...
– Felipe Duarte
Ah, I did that. I asked the question, you can look and see if that’s what you’re talking about?
– Maria
You’re consuming the API in the client, I never did that so I can’t tell you what to do, but from what I saw is based on XML, Curl also has XML support, I’ll edit with a simpler example.
– Felipe Duarte
is local, I do not have access, in fact never expose a private API link here on the site :)
– Felipe Duarte
I modified her kkk was just an example
– Maria