【发布时间】:2019-05-14 03:05:40
【问题描述】:
我试图将数据作为 JSON 传递给我的 php API。 API 使用 Wamp 托管在 localhost 中。
然后在android logcat中出现错误-
org.json.JSONException: Value <html><body><script of type java.lang.String cannot be converted to JSONObject
完整日志 -
2019-05-13 23:35:48.159 5767-5866/codecanyon.getpills I/REGISTRATION RESPONSE::: Response{protocol=http/1.1, code=200, message=OK, url=http://mywebsite.com/index.php/rest/user/login}
2019-05-13 23:35:48.163 5767-5866/codecanyon.getpills E/codecanyon.getpills.LoginActivity@ee4c317: <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("23dfd56dd81de61accd776ec4c11e6ca");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://getpills.rf.gd/index.php/rest/user/login?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>
2019-05-13 23:35:48.165 5767-5866/codecanyon.getpills W/System.err: org.json.JSONException: Value <html><body><script of type java.lang.String cannot be converted to JSONObject
2019-05-13 23:35:48.166 5767-5866/codecanyon.getpills W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
2019-05-13 23:35:48.166 5767-5866/codecanyon.getpills W/System.err: at org.json.JSONObject.<init>(JSONObject.java:163)
2019-05-13 23:35:48.166 5767-5866/codecanyon.getpills W/System.err: at org.json.JSONObject.<init>(JSONObject.java:176)
2019-05-13 23:35:48.167 5767-5866/codecanyon.getpills W/System.err: at util.CommonAsyTask.doInBackground(CommonAsyTask.java:106)
2019-05-13 23:35:48.167 5767-5866/codecanyon.getpills W/System.err: at util.CommonAsyTask.doInBackground(CommonAsyTask.java:24)
2019-05-13 23:35:48.168 5767-5866/codecanyon.getpills W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
2019-05-13 23:35:48.168 5767-5866/codecanyon.getpills W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2019-05-13 23:35:48.168 5767-5866/codecanyon.getpills W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
2019-05-13 23:35:48.169 5767-5866/codecanyon.getpills W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2019-05-13 23:35:48.169 5767-5866/codecanyon.getpills W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2019-05-13 23:35:48.169 5767-5866/codecanyon.getpills W/System.err: at java.lang.Thread.run(Thread.java:780)
然后我关注了这个帖子 -
WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server?
并改变了 -
httpd-vhosts.conf (C:\wamp64\bin\apache\apache2.4.33\conf\extra\httpd-vhosts.conf) 文件 -
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
到
<Directory "d:/wamp64/apps/phpmyadmin4.7.9/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
然后它解决了本地主机的问题
现在我想用 cPanel 对真实服务器做同样的事情
我该怎么做?
因为它显示相同的 json 错误
【问题讨论】:
-
这是与客户端相关的问题。不是服务器。
标签: php android apache http hosting