0

I have hosted REST API, that REST API can show result if opened in web browser. But if I use curlrequest in PHP to call this REST API, the response of REST API is blank / nothing. This is my curlrequest code:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://myundian.rf.gd/public/user/");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
echo $result;

Why does my curlrequest return blank response to call this REST API, but that REST API can show result if I open in web browser?

1
  • 1
    The error message that we get here is: This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support Commented Aug 7, 2022 at 6:53

1 Answer 1

1

The javascript in your site was disabled. can you enable it, and let see what the response?

i try this:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://myundian.rf.gd/public/user/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

And the response is: 'This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support'

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.