wordpress发布文章错误:此响应不是合法的JSON响应

<div class="post-text" itemprop="text"> <p>I am using PHP for the server side of my android app. The app sends the login parameters <strong>rollno</strong> and <strong>password</strong> with <code>POST</code> method. The code is fetching the result and echoing the response with <code>JSON</code>. I have hosted the same system on the live server as well as on my localhost. The live server works fine, but the local server is not echoing the response. The code is as below:</p> <pre><code>// an array to display response $response = array(); if (isset($_GET['apicall'])) { switch ($_GET['apicall']) { case 'login': // this part will handle the login // for login we need the email and password if (isTheseParametersAvailable(array( 'rollno', 'password' ))) { // getting server ip for building image url $server_ip = gethostbyname(gethostname()); // image upload path define('UPLOAD_PATH', 'uploads/'); // getting values $rollno = $_POST['rollno']; $user_password = $_POST['password']; $sql = "SELECT password from users WHERE rollno = \"$rollno\""; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { $pass_hash = $row["password"]; } if (password_verify($user_password, $pass_hash)) { // creating the query $stmt = $conn->prepare("SELECT id, username, email, gender, rollno, image, personal_notice FROM users WHERE rollno = ?"); $stmt->bind_param("s", $rollno); $stmt->execute(); $stmt->store_result(); // query for fetching fees records $feesqry = $conn->prepare("SELECT total, paid, remaining FROM fees WHERE rollno = ?"); $feesqry->bind_param("s", $rollno); $feesqry->execute(); $feesqry->store_result(); // query for fetching attendance records $attqry = $conn->prepare("SELECT mon, tue, wed, thrs, fri, sat, sun FROM attendance WHERE rollno = ?"); $attqry->bind_param("s", $rollno); $attqry->execute(); $attqry->store_result(); // query for fetching test records $tstqry = $conn->prepare("SELECT tst1_date, tst1_marks, tst1_rank, tst2_date, tst2_marks, tst2_rank, tst3_date, tst3_marks, tst3_rank, tst4_date, tst4_marks, tst4_rank, tst5_date, tst5_marks, tst5_rank FROM test WHERE rollno = ?"); $tstqry->bind_param("s", $rollno); $tstqry->execute(); $tstqry->store_result(); // query for fetching common notice $noticeqry = $conn->prepare("SELECT common_notice FROM notice"); $noticeqry->execute(); $noticeqry->store_result(); // if the user exist with given credentials if ($stmt->num_rows > 0) { $stmt->bind_result($id, $username, $email, $gender, $rollno, $image_temp, $personal_notice); $stmt->fetch(); $image = 'http://' . $server_ip . '/arsod_dynamic/' . UPLOAD_PATH . $image_temp; $feesqry->bind_result($total, $paid, $remaining); $feesqry->fetch(); $attqry->bind_result($mon, $tue, $wed, $thrs, $fri, $sat, $sun); $attqry->fetch(); $tstqry->bind_result($tst1_date, $tst1_marks, $tst1_rank, $tst2_date, $tst2_marks, $tst2_rank, $tst3_date, $tst3_marks, $tst3_rank, $tst4_date, $tst4_marks, $tst4_rank, $tst5_date, $tst5_marks, $tst5_rank); $tstqry->fetch(); $noticeqry->bind_result($common_notice); $noticeqry->fetch(); $user = array( 'id' => $id, // Various other key/values here $response['user'] = $user; } else { // if the user not found $response['error'] = false; $response['message'] = 'Invalid Roll No. or Password'; } } else { // if the user not found $response['error'] = false; $response['message'] = 'Invalid Roll No. or Password'; } } break; else { // if it is not api call // pushing appropriate values to response array $response['error'] = true; $response['message'] = 'Invalid API Call'; } // displaying the response in json structure echo json_encode($response); // function validating all the paramters are available // we will pass the required parameters to this function function isTheseParametersAvailable($params) { // traversing through all the parameters foreach($params as $param) { // if the paramter is not available if (!isset($_POST[$param])) { // return false return false; } } // return true if every param is available return true; } </code></pre> <p>The above code has line <code>echo json_encode($response);</code> the also, <code>json</code> is not returned. Please help.</p> <p>There is successful JSON output on the live server like this</p> <pre><code>{"error":false,"message":"Login successfull","user":{"id":498,"username":"Test Entry","email":null,"gender":"NA","rollno":1000,"image":"https:\/\/softglobe.net\/client-projects\/arsodclasses\/dynamic\/uploads\/default-pic.png","personal_notice":"Not available yet","common_notice":"Freedom in Mind;Faith in Words;Pride in our Heart; Memories in our Souls.Let\u2019s salute the Nation on Republic Day.HAPPY REPUBLIC DAY!","total":"-","paid":"-","remaining":"-","mon":"-","tue":"-","wed":"-","thrs":"-","fri":"-","sat":"-","sun":"-","tst1_date":"-","tst1_marks":"-","tst1_rank":"-","tst2_date":"-","tst2_marks":"-","tst2_rank":"-","tst3_date":"-","tst3_marks":"-","tst3_rank":"-","tst4_date":"-","tst4_marks":"-","tst4_rank":"-","tst5_date":"-","tst5_marks":"-","tst5_rank":"-"}} </code></pre> <p>But on the local server, nothing prints as a response.</p> </div>
解析以下响应 ``` {"errcode":"0","errmsg":"","resultcode":"0","resultmsg":"","data":{"tableCount":"1","table1_rowCount":"1","table1":[{"EntID":"123","OpenID":"001","SuppEntID":"123","SuppID":"bayrich","SuppEntName":"123","EpsType":"2","EpsCode":"sf","EpsName":"顺丰","TranType":"2","EpsParnerID":"WEICHENG","EpsParnerName":"","EpsParnerPwd":"","EpsParnerToken":"","EpsParnerSite":"","EpsParnerAccount":"9999999999","EpsDataKey":"123","EpsDataKey1":"111","OrderContent":"<?xml version="1.0" encoding="utf-8"?><Request><Header><PartnerID>123</PartnerID><PartnerToken/><VersionID>V1.1</VersionID><DocumentType/><SenderID>ISP</SenderID><ReceiverID>SFCP</ReceiverID><Timestamp>2019-12-26 11:30:34</Timestamp><RequestID>1577331034</RequestID><Language>zh-CN</Language><TimeZone>+08:00</TimeZone></Header><Body><OrderList><Order><OrderNo>66666622</OrderNo><ExpressServiceCode>1</ExpressServiceCode><IsGenMailNo>1</IsGenMailNo><ParcelQuantity>1</ParcelQuantity><TotalWeight>0</TotalWeight><PaymentMethod>1</PaymentMethod><PaymentType>1</PaymentType><PaymentAccountNo>9999999999</PaymentAccountNo><IsDoCall>0</IsDoCall><NeedReturnTrackingNo>0</NeedReturnTrackingNo><PickupMethod>2</PickupMethod><DeliveryMethod>1</DeliveryMethod><AdditionalDataList><AdditionalData><Key>cargoCount</Key><Value>2</Value></AdditionalData><AdditionalData><Key>NetWeight</Key><Value>0</Value></AdditionalData><AdditionalData><Key>CBDateTime</Key><Value>2019-12-26 11:30:34</Value></AdditionalData><AdditionalData><Key>Freight</Key><Value>0</Value></AdditionalData></AdditionalDataList><ShipFromAddress><Contact>bbb</Contact><Telephone>123</Telephone><Mobile/><CountryCode>CN</CountryCode><StateOrProvince>广东省</StateOrProvince><City>广州市</City><County>天河区</County><AddressLine1>广东省广州市天河区</AddressLine1></ShipFromAddress><ShipToAddress><Contact>aaa</Contact><Telephone>123</Telephone><Mobile/><CountryCode>CN</CountryCode><StateOrProvince>江苏省</StateOrProvince><City>南京市</City><County>浦口区</County><AddressLine1>江苏省南京市浦口区</AddressLine1></ShipToAddress><Parcels><Length>0</Length><Width>0</Width><Height>0</Height><Weight>0</Weight><Volume>0</Volume><TempRange>1</TempRange></Parcels><LineItem><ItemName>DNA基因修护早晚系列(锭状)日间</ItemName><ItemValue>0</ItemValue><ItemValueCurrencyCode>CNY</ItemValueCurrencyCode><ItemQuantity>0</ItemQuantity></LineItem><LineItem><ItemName>DNA基因修护早晚系列(锭状)夜间</ItemName><ItemValue>0</ItemValue><ItemValueCurrencyCode>CNY</ItemValueCurrencyCode><ItemQuantity>0</ItemQuantity></LineItem><CustomsItem><CustomsBatchs/><DeclaredValueCurrencyCode>CNY</DeclaredValueCurrencyCode><DeclaredValue>1283.49</DeclaredValue></CustomsItem></Order></OrderList></Body></Request>","ServiceUrl":"123","ServiceCode":"OrderService"}]}} ```
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页