我有其中有浏览器的URL中提到贝尔PHP Web服务1:
http:Domain/webservice/ACTEC_WebService.php?lastupdate=2012-09-01 01:00:00
现在,当我尝试在我的iPhone应用程序来获取URL,它正在这个网址:
http://Domain/webservice/ACTEC_WebService.php?lastupdate=2012-09-01%2001:00:00
这是创建问题。
我已经使用这个代码从我的网址获取数据。
SBJSON *json = [SBJSON new];
json.humanReadable = YES;
responseData = [[NSMutableData data] retain];
NSString *service = @"";
NSString *str;
str = @"LastUpdated";
NSString *requestString = [NSString stringWithFormat:@"{\"LastUpdated\":\"%@\"}",str];
// [[NSUserDefaults standardUserDefaults] setValue:nil forKey:@"WRONGANSWER"];
NSLog(@"request string:%@",requestString);
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *fileLoc = [[NSBundle mainBundle] pathForResource:@"URLName" ofType:@"plist"];
NSDictionary *fileContents = [[NSDictionary alloc] initWithContentsOfFile:fileLoc];
NSString *urlLoc = [fileContents objectForKey:@"URL"];
//urlLoc = [urlLoc stringByAppendingString:service];
NSLog(@"URL : %@",urlLoc);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:
[NSURL URLWithString:urlLoc]];
NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:requestData];
NSError *respError = nil;
NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: &respError ];
NSString *responseString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];
NSLog(@"Resp : %@",responseString);
if (respError)
{
// NSString *msg = [NSString stringWithFormat:@"Connection failed! Error - %@ %@",
// [respError localizedDescription],
// [[respError userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ACTEC"
message:@"check your network connection" delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
else
{
......
}
在这里,我得到的URL空响应越来越解码...我怎样才能使这个解决...帮助我。 提前致谢。