Php 尝试使用postman测试API
我正在尝试使用postman测试api,每次尝试注册时都会收到“意外的e”。 我真的不知道发生了什么 这是我的密码:Php 尝试使用postman测试API,php,api,postman,Php,Api,Postman,我正在尝试使用postman测试api,每次尝试注册时都会收到“意外的e”。 我真的不知道发生了什么 这是我的密码: $app->post('/signup', function() { $app = \Slim\Slim::getInstance(); $name = $app->request()->post('name'); $email = $app->request()->post('email'); $pass = $app->reques
$app->post('/signup', function() {
$app = \Slim\Slim::getInstance();
$name = $app->request()->post('name');
$email = $app->request()->post('email');
$pass = $app->request()->post('pass');
$app->response->setStatus(200);
$app->response()->headers->set('Content-Type', 'application/json');
try
{
$db = getDB();
$sth = $db->prepare("select count(*) as count from user WHERE email=:email");
$sth->bindParam(':email', $email, PDO::PARAM_INT);
$sth->execute();
$row = $sth->fetch();
if($row['count']>0){
$output = array(
'status'=>"0",
'operation'=>"student already registered"
);
echo json_encode($output);
$db = null;
return;
}
else{
//尝试将值插入数据库的位置
$sth = $db->prepare("INSERT INTO user (name, email,password)
VALUES(:name,:email,:pass)");
$sth->bindParam(':name', $name, PDO::PARAM_INT);
$sth->bindParam(':email', $email, PDO::PARAM_INT);
$sth->bindParam(':pass', $pass, PDO::PARAM_INT);
$sth->execute();
$output = array(
'status'=>"1",
'operation'=>"success"
);
echo json_encode($output);
$db = null;
return;
}
}
catch(Exception $ex){
echo $ex;
}
});
发生“意外的e”是因为Postman希望输出是JSON响应
收到响应后,单击“原始”或“预览”选项卡。或者从下拉菜单中选择其他格式之一。您将看到其余的响应
发生“意外的e”是因为Postman希望输出是JSON响应
收到响应后,单击“原始”或“预览”选项卡。或者从下拉菜单中选择其他格式之一。您将看到其余的响应
你在《邮差》中的贴身造型是什么?你得到了什么样的回应?401? 403? 500?你在《邮递员》里的身体是什么样子的?你得到了什么样的回应?401? 403? 500?