I am trying to fill up a web form and submit data without letting the user see the web form itself. I have tried using AFNetworking to do HTTP POST in the background, but I bumped into a problem which I couldn't solve and decided to try something else.
This time, I have a UIWebView
which is hidden in the background. I then edit the text in the respective fields using Javascript in the webViewDidFinishLoad:webView
as follows:
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:nameField.text forKey:@"name"];
[params setObject:emailField.text forKey:@"email"];
[params setObject:titleField.text forKey:@"title"];
[params setObject:dateString forKey:@"link"];
[params setObject:descriptionTV.text forKey:@"content"];
[params setObject:tag forKey:@"tags"];
[params enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) {
NSLog(@"%@ = %@", key, object);
NSString *javascriptString = [NSString stringWithFormat:@"document.getElementById('%@').value = '%@'",key,object];
[webView stringByEvaluatingJavaScriptFromString:javascriptString];
}];
Is there any way I could do the same, but for uploading images/files?