php提交参数是否为空,php – Alamofire请求参数为空

我正在尝试使用Alarmofire库发送POST请求,但请求不会正确发送参数.

我的代码:

let parameters : Parameters = [

"email": tfLoginEmail.text! as String,

"password": tfLoginPassword.text! as String

]

Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON{ response in

//Some code that uses the response

}

参数变量的计数为2且两个值都存在,但对此请求的响应是关于电子邮件和/或密码为空的错误.

编辑:

我的PHP:

/**

* Account Login

* url - /login

* method - POST

* params - email, password

*/

$app->post('/login', function() use ($app) {

// check for required params

verifyRequiredParams(array('email', 'password'));

// reading post params

$email = $app->request()->post('email');

$password = $app->request()->post('password');

$response = array();

$db = new DbHandler();

// check for correct email and password

if ($db->checkLogin($email, $password)) {

// get the user by email

$account = $db->getAccountByEmail($email);

if ($account != NULL) {

$response["error"] = false;

$response['id'] = $account['id'];

$response['name'] = $account['name'];

$response['email'] = $account['email'];

} else {

// unknown error occurred

$response['error'] = true;

$response['message'] = "An error occurred. Please try again";

}

} else {

// user credentials are wrong

$response['error'] = true;

$response['message'] = 'Login failed. Incorrect credentials';

}

echoRespnse(200, $response);

});

我想知道我做错了什么.

提前致谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值