[英]Simple Post Request with Alamofire
It's my first post here, I'm trying to do this with Alamofire: 这是我的第一篇文章,我正在尝试使用Alamofire进行此操作:
Swift code: SWIFT代码:
let name = "Taza"
let description = "50cl"
let parameters = ["name": name, "description": description]
Alamofire.request(.POST, "http://xxxxx.es/JSONpresenter.php?op=5", parameters: parameters, encoding: .JSON);
PHP code: PHP代码:
$op=$_GET['op'];
else if($op == 5)
{
// Get user id
$name = isset($_POST['name']) ? mysql_real_escape_string($_POST['name']) : “”;
$description = isset($_POST['description']) ? mysql_real_escape_string($_POST['description']) : “”;
add($name,$description);
}
But only get a register with "" in all cells. 但是在所有单元格中只能获得带有“”的寄存器。 What am I doing wrong? 我究竟做错了什么?
在这种情况下,您需要使用URLEncoding而不是JSONEncoding
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.