我想从web服务获取json数据需要访问权限,当我输入Web服务的url时,它要求我输入用户名和密码,我不知道如何通过这些我的代码在xcode中有两个参数,我试过这样做,但它没有用,有任何想法请
NSURL *aUrl = [NSURL URLWithString: @"http://firstluxe.com/api/search/search?query=vogue&language=1&output_format=JSON"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request addValue:[NSString stringWithFormat:@"OAuth %@", password] forHTTPHeaderField:@"Authorization"];
[request setHTTPMethod:@"GET"];
NSError *error = nil;
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error: &error];
NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:returnData options:kNilOptions error:&error];
NSLog(@"Response : %@", JSONDictionary);