我创建了一个Android + iOS应用,它使用API来检索JSON格式的一些内容。在我将所有专用服务器迁移到新服务器之前,一切运行良好。在新服务器中,这两个应用程序不再像以前那样获得JSON。当应用程序调用API时,应用程序会崩溃,例如:
org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.libraries.JSONParser.getJSONFromUrl(JSONParser.java:43)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.libraries.UserFunctions.confirmDeal(UserFunctions.java:161)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.ScreenSlidePageFragment$ConfirmDeal.doInBackground(ScreenSlidePageFragment.java:466)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.ScreenSlidePageFragment$ConfirmDeal.doInBackground(ScreenSlidePageFragment.java:440)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.lang.Thread.run(Thread.java:818)
我认为这与服务器有关,但我无法弄清问题是什么。我无法在日志中找到有关该信息的任何信息..
以下是Android应用中的代码:
public JSONObject confirmDeal(int valueStartIndex, String deal_id,String imei,String imsi,String android_id){
Log.d("Krown", "UserFunctions >> confirmDeal 1");
webService = URLApi+service_confirm_deal+param_deal_id+deal_id+"&"+param_imei+imei+"&"+param_imsi+imsi+"&"+param_android_id+android_id;
JSONObject json = jsonParser.getJSONFromUrl(webService);
Log.d("Krown", "UserFunctions >> confirmDeal >> webService: "+webService);
Log.d("Krown", "UserFunctions >> confirmDeal 2");
return json;
}
此时应用程序崩溃了:
webService = URLApi+service_confirm_deal+param_deal_id+deal_id+"&"+param_imei+imei+"&"+param_imsi+imsi+"&"+param_android_id+android_id;
JSONObject json = jsonParser.getJSONFromUrl(webService);
知道如何解决这个问题吗?我不知道我应该在哪里寻找解决方案......
修改
以下是我在尝试获取JSON时从服务器获得的内容
07-13 16:32:45.049 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/currency was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
07-13 16:32:45.103 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/latest_deals_day was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
07-13 16:32:45.155 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/latest_deals_night was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
那是什么?我安装了几个网站,除了这个API,一切都运行良好..
编辑2
我试图打电话的网址是这样的:
http://mywebsite.com/eat_out/api/confirm_deal?deal_id=&imei=000000000000000&imsi=310260000000000&android_id=b798c307f7d128f4
编辑3
网址http://mywebsite.com/eat_out/api/confirm_deal无法访问,可能与之相关.. :(
未找到
在此未找到请求的网址/ eat_out / api / confirm_deal 服务器
这个问题可能与PHP配置中缺少的扩展或直接与PHP有关吗?我在新服务器中使用PHP 7。