【发布时间】:2011-09-04 18:39:52
【问题描述】:
我正在编写一个 iPhone 应用程序并尝试使用 JSON 对象向 drupal 服务器发送 POST 请求,但它总是返回我
{"#error":true,"#data":"方法无效
我尝试了以下操作:
NSMutableURLRequest *urlReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxxxxxx/services/json"]];
[urlReq setHTTPMethod:@"POST"];
[urlReq setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *stringBody = @"{data:{\"method\":\"views.get\",\"view_name\":\"words\",\"args\":[\"wod_businessspotlight\"],\"limit\":365}}";
NSData *dataBody = [stringBody dataUsingEncoding:NSUTF8StringEncoding];
[urlReq setValue:[NSString stringWithFormat:@"%d", [dataBody length]] forHTTPHeaderField:@"Content-Length"];
[urlReq setHTTPBody:dataBody];
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:urlReq delegate:self];
[con start];
我在iPhone + Drupal + JSON RPC Server problem 看到过类似的问题,但没有提到在哪里可以找到 SBJSON 类和 JSONFragment 方法。
我也下载了https://github.com/stig/json-framework/,但在任何地方都找不到 JSONFragment 方法。**
请帮我解决这个问题。 提前致谢。
【问题讨论】:
标签: javascript objective-c drupal