这是我第一次通过 HTTP 请求处理服务器通信,为了确定我在做什么,并且有“我的双手之间的事情”,我想打印服务器应该返回给我的 xml 文件. 如果有人可以帮助我,请:
这是我的代码:
(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if ([stories count] == 0) {
NSString * l_api_key = @"********************************************";
NSString * l_secret_key = @"******************************************";
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:[@myURLHERE stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"application/xml" forHTTPHeaderField:@"Accept"];
[theRequest setValue:@"application/x-www-form-unrlencoded" forHTTPHeaderField: @"Content-Type"];
[theRequest addValue:l_api_key forHTTPHeaderField: @"EMApikey"];
[theRequest addValue:[self hmacsha1:l_api_key secret:l_secret_key] forHTTPHeaderField: @"EMRequestHash"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(@"%@", theConnection);
if( theConnection )
{
NSData *webData = [[NSMutableData data] retain];
NSLog(@"%@", webData);
//[self parseXMLFileAtURL:path];
}
else
{
NSLog(@"theConnection is NULL");
}
[theConnection release];
}
cellSize = CGSizeMake([newsTable bounds].size.width, 60);
}