简体   繁体   中英

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

I have created API services using PHP and it works fine on my local(xampp)

However, when I host the files online, it return junk HTML instead of JSON response. The response I receive is something similar to this:

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

Can someone please advise what I may be doing wrong?

Have you checked that the website hasn't been hacked? - This looks like some obfuscated code.

The basic reason might be you have disabled browser cookies or disabled javascript. Since free hosting services required to set a cookie for better services in (my case byethost) and cookies required javascript to be enabled. So it has nothing to do with code but with the hosting server, you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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