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

}


类别:网络部分 查看评论
posted on 2011-03-08 17:13  AnMog  阅读(233)  评论(0编辑  收藏  举报