var SubmitDic = NSMutableDictionary ()
SubmitDic.setObject (loginMerged, forKey: "module" )
SubmitDic.setObject (kedahE-tutorApp, forKey: "wsKey" )
SubmitDic.setObject (112211, forKey: "passwd" )
SubmitDic.setObject (form04, forKey: "userName" )
var request : NSMutableURLRequest = NSMutableURLRequest()
request.URL = NSURL(string: http://kedah-etutor.com/component/module/ws_function2.php)
request.HTTPMethod = "POST"
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(SubmitDic, options: NSJSONWritingOptions() , error: nil)
println(NSJSONSerialization.dataWithJSONObject(SubmitDic, options: NSJSONWritingOptions() , error: nil)?.description)
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler:{ (response:NSURLResponse!, data: NSData!, error: NSError!) -> Void in
var error : AutoreleasingUnsafeMutablePointer<NSError?> = nil
if data != nil
{
}
我试图调用php json Web服务,但是它返回null数据并且错误描述一直提到“网络连接丢失”。此外,在Java中,HttpClient框架可以很好地与PHP Web服务配合使用。