Reputation: 1
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?
Upvotes: 0
Views: 322
Reputation: 139
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'
Upvotes: 1