ios - 使用 Alamofire 进行简单的发布请求

标签 ios swift alamofire

这是我在这里发表的第一篇文章,我正在尝试使用 Alamofire 来做到这一点:

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 代码:

$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);

}

但只能获取所有单元格中带有“”的寄存器。我做错了什么?

最佳答案

对于这种特殊情况,您需要使用 URLEncoding 而不是 JSONEncoding

关于ios - 使用 Alamofire 进行简单的发布请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30798920/

相关文章:

ios - View Controller 容器偶尔会错过子 Controller 中的 viewWillAppear

ios - 更改 UIView 边框的形状

ios - iPhone 上的应用程序测试,崩溃日志在哪里?

ios - 登录页面未完全注销用户 iOS

ios - 由于未捕获的异常 'NSRangeException' 而终止应用程序,原因 : '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'

ios - 通过 Segue 转发数据(objective-c)

iphone - Obj-c IOS 内存管理

ios - Facebook 无法在 app swift 3 中打开页面

ios - swift 无法转换类型的值

ios - 全局 Alamofire 请求(AppDelegate)