简体   繁体   English

PHP curl REST API 返回无响应

[英]PHP curl REST API returning no response

I have hosted REST API, that REST API can show result if opened in web browser. 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. 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:这是我的 curlrequest 代码:

$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? 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?

The javascript in your site was disabled.您站点中的 javascript 已禁用。 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 '响应是:'此站点需要 Javascript 才能工作,请在浏览器中启用 Javascript 或使用支持 Javascript 的浏览器'

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM