【发布时间】:2010-09-07 08:26:57
【问题描述】:
我正在使用 JSON 框架开发 iPhone 应用程序,我正在调用 PHP 脚本来更新本地服务器上的 MySQL 数据库。使用这些代码:
NSString *jsonString = [sendData JSONRepresentation];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString*post = [NSString stringWithFormat:@"&json=%@", jsonString];
NSData*postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
[request setURL:[NSURL URLWithString:@"http://localhost:8888/update.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPBody:postData];
我想问一下:
什么是从该请求中获取数据的 PHP 脚本,以及如何将 JSON 数据解码为 PHP 对象以更新到数据库?
任何帮助将不胜感激。
【问题讨论】:
标签: php iphone mysql cocoa-touch json