I am trying to edit the wikitext of a page using a textView and save it on the server using mediawiki API as follows:
- (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);
}
but I am getting an error : internal_api_error_MWException, Exception Caught: Detected bug in an extension! Hook iaifAPIEditBeforeSave has invalid call signature; Parameter 1 to iaifAPIEditBeforeSave() expected to be a reference. Searched about the error on google but I didn't find anything. Please suggest something.
That wiki appears to have an outdated Data Import Extension. Update/uninstall as required. A quick hack that should fix this particular error would be to replace function iaifAPIEditBeforeSave(&$editPage, $text, &$resultArr)
with function iaifAPIEditBeforeSave($editPage, $text, &$resultArr)
in extensions/DataImport/IAI/includes/IAI_GlobalFunctions.php, however I don't know what else could be outdated/broken there.