Empty PHP API request page

Asked

Viewed 312 times

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); }

  • tried with pure CURL at the terminal?

  • @Lfziron Still getting a blank page.

  • @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íciacastropereira has already tried to use curl_setopt($ch, CURLOPT_RETUNTRANSFER, 1);

  • @Lfziron had tried before, tried again and with the same result.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.