0
I’m writing a web platform that uses Sptrans RESTFUL API - Living Eye. Authenticate my session with the code:
<?php
$url = 'http://api.olhovivo.sptrans.com.br/v2.1/Login/Autenticar?token='.token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "");
$result = curl_exec($curl);
curl_close($curl);
echo $result;
?>
Who returns to me
True
When I try to use the API elsewhere in the code, I have authentication problems.
<?php
$url = 'http://api.olhovivo.sptrans.com.br/v2.1/Linha/Buscar?termosBusca=8000';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
echo $result
?>
returning
{"Message":"Authorization has been denied for this request."}
What am I doing wrong?
Thank you
Voce checked if you need to pass some webtoken? And the so-called method accepts get request?
– tkmtts
@tkmattos sim precisa. The method is called via POST /Login/Authenticate? token={token} and the second is GET
– Filipe Filardi