Http请求突然无法正常工作

时间:2015-08-08 11:47:40

标签: java php android json mysqli

我正在开发两个使用相同在线服务器访问mysqli数据库的应用程序。在不久之前,它们都运行良好,但是现在当我使用http get请求从我的数据库加载JSON格式的数据时,它们都会因为null异常而崩溃。我在线查看了响应是什么,而不是看到一直加载的JSON数据,我突然看到了这一点。我不确定服务器是否进行了一些更改或发生了什么,但我无法从我的在线数据库中加载任何数据。

<html>
  <body>
    <h2>Checking your browser..
      <h2>
        <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("7c1b95c2ae1fc0d11f10c396f4889bf1");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";location.href="http://****?ckattempt=1";
          </script>
        </body>
      </html>

编辑

提出请求的Asynctask(相当标准,之前工作完全正常;不在代码中发行)

 protected String doInBackground(String... args) {
            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36"));

            // getting JSON string from URL
            JSONObject json = jParser.makeHttpRequest(url_all_gamess, "GET", params);

            // Check your log cat for JSON reponse
            Log.d("All Questions:", json.toString());

            try {
                // Checking for SUCCESS TAG
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {
                    // products found
                    // Getting Array of Games
                    allquestions = json.getJSONArray(TAG_GAMELIST);

                    // looping through All Products
                    for (int i = 0; i < allquestions.length(); i++) {
                        JSONObject c = allquestions.getJSONObject(i);

                        // Storing each json item in variable
                        String id = c.getString(TAG_ID);
                        String zadanie = c.getString(TAG_ZADANIE);
                        String odp_a = c.getString(TAG_ODP_A);
                        String odp_b = c.getString(TAG_ODP_B);
                        String odp_c  = c.getString(TAG_ODP_C);
                        String odp_d = c.getString(TAG_ODP_D);
                        String commentfirst = c.getString(TAG_COMMENTFIRST);
                        String comment = c.getString(TAG_COMMENT);
                        String correctanswer = c.getString(TAG_CORRECTANSWER);
                        Log.d("id",id);
                        Log.d("zadanie",zadanie);
                        Log.d("ansa",odp_a);
                        Log.d("ansb",odp_b);
                        Log.d("ansc",odp_c);
                        Log.d("comment",comment);
                        Log.d("correctans",correctanswer);
                        Log.d("commentfirst",commentfirst);


                        questionabcd a = new questionabcd(zadanie,odp_a,odp_b,odp_c,odp_d,correctanswer,comment,commentfirst);
                        Log.d("questionabcd", a.toString());
                        // creating new HashMap

                        // adding HashList to ArrayList
                        questions.add(a);

                    }

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return "";
        }

错误:

08-08 15:52:18.714  28394-28476/com.example.albert.mathapp E/JSON Parser﹕ Error parsing data org.json.JSONException: End of input at character 0 of
08-08 15:52:18.754  28394-28476/com.example.albert.mathapp E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: com.example.albert.mathapp, PID: 28394
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:300)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
            at com.example.albert.mathapp.MainActivity$LoadAllQuestions.doInBackground(MainActivity.java:94)
            at com.example.albert.mathapp.MainActivity$LoadAllQuestions.doInBackground(MainActivity.java:70)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

0 个答案:

没有答案