1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | var url = "https://v.1dq.com/api/bank/v4" var httpArg = "key=您申请的key&bankcard=62220211111&realName=张三&cardNo=12345678&Mobile=15618181818&cardtype=&information=" APISLA(url, httpArg: httpArg) func APISLA(httpUrl: String, httpArg: String) { var req = NSMutableURLRequest(URL: NSURL(string: httpUrl + "?" + httpArg)!) req.timeoutInterval = 6 req.HTTPMethod = "GET" NSURLConnection.sendAsynchronousRequest(req, queue: NSOperationQueue.mainQueue()) { (response, data, error) -> Void in let res = response as ! NSHTTPURLResponse println(res.statusCode) if let e = error{ println( "请求失败" ) } if let d = data { var content = NSString(data: d, encoding: NSUTF8StringEncoding) println(content) } } } |