Monday 15 September 2014

ios - ASIHTTPRequest - Post JSON to PHP -


I have used ASIHTTPRequest to post a php script in the data without any problems. This is my first time trying to send JSON and I can not do it at work.

  NSError * Error = zero; NSMutableDictionary * jsonDict = [Object with NSMutableDictionary dictionary: for object array: keyre]; [JsonDict Set Object: email forKey: @ "email"]; NSDTA * JSNET Data = [NSJSANsErilization DatavidJSNONJect: JasonDict Options: NSJSrunning Prattiprint Error: & amp; Error]; NSURL * url = [NSURL URLWithString: @ "http://192.168.1.12:8888/Folder/script.php"]; __bloc ASIHTTPRequest * Request = [ASIHTPP request request with url: url]; [Request Security Mode: @ "Post"]; [Add request postdata: jason datas]; [Request addRequestHeader: @ "content-type" value: @ "app / jason"]; [Request setcompletionBlock: ^ {NSString * responseString = [request response string]; NSLog (@ "finished text:% @", response string); }]; [Request setFailedBlock: ^ {NSError * error = [request error]; NSLog (@ "unsuccessful:% @", error); }]; [Request Asamenus];   

PHP script is still fine

    

As a result: array () . Nothing is coming. Any idea what the problem might be?

This is not a problem in your purpose-c code, but looking at your PHP scripts. When the data is not sent as application / x-www-form-urlencoded , then you have to read the data.

No comments:

Post a Comment