发送GET请求时发送错误的网址请求

时间:2013-11-19 04:38:12

标签: iphone objective-c ios6

http://<url>/<abc>.php?email=<email_id>&datadict=<json dictionary>&id=<id>

以上是我在GET中发送的获取请求网址。但是xcode正在创建“Bad Url”错误。 我已经使用NSUTF8StringEncoding创建了一个有效的URL。 我正在为ios 6开发。 任何人都可以帮助我吗?

以下是我的代码:

serviceUrl = @"http://<url>/<abc>.php?

NSMutableString* theString = [NSMutableString string];

[theString appendString:[NSString stringWithFormat:@"%@email=",serviceUrl]];

[theString appendString:[NSString stringWithFormat:@"%@",[myDict objectForKey:@"email"]]];
[theString appendString:[NSString stringWithFormat:@"&datadict=%@&",[myDict objectForKey:@"confirmation"]]]; 
 //paypal payment gateway confirmation in json
//NSString* udidEncoded = [[myDict objectForKey:@"udid"] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[theString appendString:[NSString stringWithFormat:@"udid=%@",[[UIDevice currentDevice] identifierForVendor].UUIDString]];
NSLog(@"concat : %@", theString);


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:theString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:900.0];

return request; 

0 个答案:

没有答案