网易云信 短信接口Swift 调用

func getCode() {
    
    let time = timeStamp()//时间戳
    let ran = ranmdow()//5位随机数
    let check = "App Secret" + ran + time
    let checkS = check.sha1()//哈希加密
    let headers:HTTPHeaders = ["AppKey": "860530e167045b943e5aff37e69d58b1","CurTime": "\(time)","CheckSum": "\(checkS)","Nonce": "\(ran)","Content-Type": "application/x-www-form-urlencoded;charset=utf-8"]
    let parameters = ["mobile":"手机号"]
    Alamofire.request("https://api.netease.im/sms/sendcode.action", method: .post, parameters: parameters, encoding: URLEncoding.default, headers: headers).responseJSON { (response) in
        if response.result.isSuccess {
            print(response.result.value)
        } else {
            print(response.result.error)
        }
    }


  

}

你可能感兴趣的:(网易云信 短信接口Swift 调用)