网络数据请求

NSString* url = [NSString stringWithFormat:@"%s?mt=1&qt=6045&mobilekey=%@", gURLHEADER.getData(), [[UIDevice currentDevice] uniqueIdentifier]];

NSURL *c_url = [NSURL URLWithString:url];

NSMutableURLRequest *postRequest = [[NSMutableURLRequest alloc] initWithURL:c_url];

[postRequest setHTTPMethod:@"POST"]; [postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];

[postRequest setTimeoutInterval:60];

NSHTTPURLResponse* response = nil;

NSData *resData = nil;

NSInteger code = 0;

int index = 0;

while (index < 2)

{

resData= [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:nil];

code = [response statusCode];

if (code == 200)

{

break;

}

index++;

}

[postRequest release];

if (resData)//服务器返回的数据

{

//用xml方式解析resData

}


类别: 网络部分  查看评论

你可能感兴趣的:(数据)