使用Alamofire在swift 3.0中发布url问题

时间:2017-04-05 08:44:39

标签: swift alamofire

我正在尝试发送短信,而我的网址号码是“http://api.appname.my/sendSms.php?message=hello&phone=687985< 6123488< 60149041982”,但它会缩短到这个“http://api.appname.my/sendSms.php?message=hello&phone=687985”,所以为什么要删除其他数字。这是我的代码

{{1}}

1 个答案:

答案 0 :(得分:1)

我认为您应该将<字符编码为%3C

let urlString = "http://api.appname.my/sendSms.php?message=hello&phone=\(number)"
let url = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
print("Result: " + url!)

// Result: http://api.appname.my/sendSms.php?message=hello&phone=687985%3C6123488%3C60149041982