Php Swift中的API函数调用返回无效的JSON响应,尽管函数正在成功运行

Php Swift中的API函数调用返回无效的JSON响应,尽管函数正在成功运行,php,swift,codeigniter,Php,Swift,Codeigniter,中只有JSON响应以无效格式返回。API中的函数正在成功运行 public function registertoken_post(){ $json=file\u get\u contents('php://input'); $dataDB=json_decode($json,true); $email=$dataDB['email']; $token=$dataDB['token']; $check=$this->body\u model->registerToken($email,$toke

中只有JSON响应以无效格式返回。API中的函数正在成功运行

public function registertoken_post(){
$json=file\u get\u contents('php://input');
$dataDB=json_decode($json,true);
$email=$dataDB['email'];
$token=$dataDB['token'];
$check=$this->body\u model->registerToken($email,$token);
如果($check==0)
{
$response['message']=“令牌编辑成功”;
$response['status']=“成功”;
$log=json_encode($response);
echo$log;
}
else if($check==1)
{
$response['message']=“无法编辑令牌”;
$response['status']=“失败”;
$log=json_encode($response);
//返回$log;
echo$log;
}
其他的
{
$response['message']=“未找到电子邮件”;
$response['status']=“失败”;
$log=json_encode($response);
echo$log;
}
}
导致Swift:

错误:

Error Domain=NSCOCAERRORDOMAIN Code=3840“JSON文本未以数组或对象开头,允许未设置片段的选项。”UserInfo={NSDEBUGSCRIPTION=JSON文本未以数组或对象开头,允许未设置片段的选项。}

响应JSON:

预期的JSON:

{
    "message": "Token edited successfully",
    "status": "Success"
}

我不确定问题是什么?API是否输出正确的格式(JSON),但通过swift应用程序访问API时,响应的格式不同?是的,输出的格式不同。很明显,响应JSON不是有效的JSON,这意味着API中的函数未成功运行。服务器端代码可能有一些调试输出,显示
http://192.168.1.204:8080/sv/
,查找并删除该行。@OOPer Response JSON:您需要找到PHP代码中生成响应的行。