HTMLページを取得して解析したい。
http://gdata.youtube.com/feeds/api/videos?q=u_dAYLIG984に送信します
NSURL* url = [NSURL URLWithString: fullPath];
NSMutableDictionary* headers = [[[NSMutableDictionary alloc] init] autorelease];
[headers setValue:@"application/x-www-form-urlencoded;charset=utf-8" forKey:@"Content-Type"];
[headers setValue:@"text/html" forKey:@"Accept"];
[headers setValue:@"no-cache" forKey:@"Cache-Control"];
[headers setValue:@"no-cache" forKey:@"Pragma"];
[headers setValue:@"close" forKey:@"Connection"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:TIMEOUT_REQUEST];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
conn = [[NSURLConnection alloc] initWithRequest:request delegate:delegate startImmediately:YES];
私はいつも403エラーになります。なにが問題ですか ?
編集:
http://bbc.co.uk/でリクエストを試してみましたが、うまくいきました。http://gdata.youtube.com/feeds/api/videos?q=u_dAYLIG984のみの問題
EDITED2:
@Christophe Debove、あなたは正しいです。リクエストを POST から GET に変更したところ、406 エラーが発生しました。「Accept」ヘッダーを削除したら動くようになりました。Google開発者キーがなくても機能します。