Php 如何在swift 4中从iOS向MySql数据库发送数据

Php 如何在swift 4中从iOS向MySql数据库发送数据,php,ios,swift,Php,Ios,Swift,我试着用谷歌搜索它,但所有的教程都在swift 3或以下版本中。我所知道的是,您必须在swift中使用JSONEncoder,并且必须从swift发送JSON数据 感谢您的帮助。通过此链接了解如何安装Alamofire 使用此代码将数据发送到服务器 // https://www.yourAPIHostedWebsite.com/endpoints/ let url = "http://www.example.com/index.html?name=santosh&country=nep

我试着用谷歌搜索它,但所有的教程都在swift 3或以下版本中。我所知道的是,您必须在swift中使用JSONEncoder,并且必须从swift发送JSON数据


感谢您的帮助。

通过此链接了解如何安装Alamofire

使用此代码将数据发送到服务器

// https://www.yourAPIHostedWebsite.com/endpoints/
let url = "http://www.example.com/index.html?name=santosh&country=nepal"

Alamofire.request(url, method: .get)
    .validate(statusCode: 200..<300)
    .responseJSON { response in
        print(response)
}.resume()
//https://www.yourAPIHostedWebsite.com/endpoints/
让url=”http://www.example.com/index.html?name=santosh&country=nepal"
请求(url,方法:.get)

.validate(statusCode:200..你到底想实现什么?你不能直接将JSON发送到MySQL,你需要在两者之间创建一些API层。如何实现这一点对于StackOverflow来说太广泛了,但你需要做一些研究。我想使用swift 4将数据从iOS发送到MySQL数据库
<?php
$name = $_GET["name"];
$country = $_GET["country"];

if($name || $country) {
// Now store these values to your database. 
}
?>