我想获得链接的.csv文件,该文件在发布到http表单后可用。 URL(代码为kURL)为http://www2.htw-dresden.de/~rawa/cgi-bin/auf/raiplan_kal.php。 我试图用得到的结果:连续执行HTTP帖子Obj C
NSString *myRequestString = [NSString stringWithFormat:@"unix=%@&pressme=%@",_password,@"S+T+A+R+T"];
NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:kURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPBody: myRequestData];
[request setValue:@"4" forHTTPHeaderField:@"w1"];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (connectionError) NSLog(@"ERROR: %@", [connectionError localizedDescription]);
else {
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", string);
}
}];
至于结果,我得到:
...
<form name=Testform method=post action=../plan/t21.csv><INPUT TYPE=hidden NAME=w1 value=4></form><script type="text/javascript">
function AbGehts() {document.Testform.submit();}
window.setTimeout("AbGehts()",1);
</script>
...
我需要的是JavaScript功能AbGehts后创建的文件()。但我怎么能得到这个?
我希望你能帮助我不认为需要这种形式的密码,我不能发布这个..
所以你没有合适的Web服务调用?你不能添加一个?你不能编码JavaScript的任何重定向到应用程序? – Wain
我不知道我明白你的意思。我所称的网络服务是在我的大学运行的一项服务。我希望在第一次请求后隐藏表单后面的数据。 – Ben