我正在尝试使用 textView 编辑页面的 wikitext 并使用 mediawiki API 将其保存在服务器上,如下所示:
- (void)saveAction{
NSString *savedString = textView.text;
NSString *baseurl=[[NSUserDefaults standardUserDefaults] stringForKey:@"url_preference"];
NSString *page=[[baseurl stringByAppendingString:@"/api.php?**action=edit&title=Testedit&text=savedString&token=**"] stringByAppendingString:[MySingleton sharedSingleton].token];
NSData *data=[savedString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postlength=[NSString stringWithFormat:@"%d",[data length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:page]];
[request setHTTPMethod:@"POST"];
[request setValue:postlength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:data];
NSError *error=nil;
NSURLResponse *response=nil;
NSData *result=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *HTMLString2 = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];
NSLog(@"%@", HTMLString2);
}
但我收到一个错误: internal_api_error_MWException, Exception Caught: Detected bug in an extension!Hook iaifAPIEditBeforeSave 调用签名无效;iaifAPIEditBeforeSave() 的参数 1 应为参考。在谷歌上搜索错误,但我没有找到任何东西。请提出一些建议。