パラメータを取る URL があります。Firefox で。アドオンをダウンロードして、リクエストのパラメーターを見つけました。httpFox アドオン ツールで PostData タブを見つけ、パラメーターと値を確認しました。
文字列を作成してパラメーターを追加し、その文字列値をエンコードしました
NSString *parameterId = [NSString StringWithFormat:@"ac$2_sdrex_es34_4333f=Caa111"];
NSString EncodeID = [parameterId
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
...そして PostData を作成し、
PostData = [encodeID dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
...そして postLength を設定し、
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
...そして、http ヘッダー値を設定します。
[request setValue:postLength forHttpHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
そして接続を行い、
connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
しかし、これにより次のエラーが発生します...
Error Domain = NSURLErrorDomain code= -1002 unsupported url
URLもエンコードしました。
この問題を解決する方法を教えてもらえますか?
これがpostDataを作成した後のものです!
NSURL *url = [NSURL URLWithString:urlString];
theRequest = [[NSMutableURLRequest alloc]initWithURL:url];
[theRequest setValue:@"win-eqjf1b1ep06:20000" forHTTPHeaderField:@"Host"];
[theRequest setValue:@"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" forHTTPHeaderField:@"User-Agent"];
[theRequest setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
[theRequest setValue:@"en-us,en;q=0.5" forHTTPHeaderField:@"Accept-Language"];
[theRequest setValue:@"gzip,deflate" forHTTPHeaderField:@"Accept-Encoding"];
[theRequest setValue:@"ISO-8859-1,utf-8;q=0.7,*;q=0.7" forHTTPHeaderField:@"Accept-Charset"];
[theRequest setValue:@"115" forHTTPHeaderField:@"Keep-Alive"];
[theRequest setValue:@"keep-alive" forHTTPHeaderField:@"Connection"];
[theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:postData];
@all よろしくお願いします