PHP - API文件在在线托管时返回垃圾HTML而不是JSON响应


PHP - API file returning junk HTML instead of JSON response when hosted online

我使用PHP创建了API服务,它在我的本地(xampp)上运行良好

然而,当我在线托管文件时,它返回垃圾HTML而不是JSON响应。我收到的响应类似于以下内容:

<html>
<body>
<script type="text/javascript" src="/aes.js" ></script>
<script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f
  <d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("6f52ec93eff14fb17fe0ff4703436db4");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";location.href="http://example.com/?ckattempt=1";
  </script>
  <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
</body>

谁能告诉我我可能做错了什么?

你检查过网站没有被黑吗?

基本原因可能是您禁用了浏览器cookie或禁用了javascript。因为免费托管服务需要设置一个cookie以获得更好的服务(我的例子是通过yethost),而cookie需要启用javascript。所以它与代码无关,而是与您正在使用的托管服务器有关。