最後に、ASI-xx が機能するようになったので、ARC コンパイル エラーやその他の欠落は発生しません。
ここで、アプリケーションから直接 Web サイトにログインできるように ASIFormDataRequest を試してみたいと思います。
これは私がすでに得たものですが、正しく動作していないようです:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
NSString *str = @"http://mysite.com/ucp.php?module=login";
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"username" forKey:@"username"];
[request setPostValue:@"password" forKey:@"password"];
[request setTimeOutSeconds:120];
[request setDelegate:self];
[request startAsynchronous];
NSLog(@"%@",[request responseString]);
NSLog(@"%d",[request responseStatusCode]);
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mysite.com"]]];
[self.view addSubview:webView];
}
WebView を削除しても、画面には何も表示されません。
NSLog の結果は次のとおりです。
(null)
0
データを POST したい(ウェブサイトの)テキストフィールドには、次のコードがあります:
<input tabindex="1" name="username" id="username" size="25" value="" class="inputbox autowidth" type="text">
<input tabindex="2" name="password" id="password" size="25" value="" class="inputbox autowidth" type="text">
どんな助けでも感謝します:)