0
I’m trying to make a request for the url:
http://api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=XXXX
and the response if token
valid should be true
.
I’ve tried several ways using Curl
and GuzzleHttp
, all return one to me Blank page. I tested the token
on Postman and it works.
I am in the learning curve of language and I would like to know the simplest and functional way and see the return on the page.
Thank you in advance.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://api.olhovivo.sptrans.com.br/v0/Login/Autenticar");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "?token=XXXX");
$result = curl_exec ($ch);
curl_close ($ch);
print_r($result);
before you run curl_close, check if there has been an error and display the error on the screen. If there is, post here please. Checking for error in Curl: if(curl_exec($ch) === false) { echo 'Curl error: ' . curl_error($ch); }
– LF Ziron
tried with pure CURL at the terminal?
– pmargreff
@Lfziron Still getting a blank page.
– Letícia Castro Pereira
@pmargreff Seeing some tutorials I get errors, would you have any say to do the post request via terminal? ERROR:"No HTTP Resource was found that Matches the request URI". I think there may be some error regarding the data and the root URL which is "http://api.olhovivo.sptrans.com.br/v0/", can tell me what is parameter, data and how to pass them?
– Letícia Castro Pereira
@Letíciacastropereira has already tried to use curl_setopt($ch, CURLOPT_RETUNTRANSFER, 1);
– LF Ziron
@Lfziron had tried before, tried again and with the same result.
– Letícia Castro Pereira