NSString *phone = [NSString stringWithFormat:@"phone=%@",[paymentServerData valueForKey:@"phone"]];
NSString *key = [NSString stringWithFormat:@"key=%@",[paymentServerData valueForKey:@"key"]];
NSString *furl = [NSString stringWithFormat:@"furl=%@",[paymentServerData valueForKey:@"furl"]];
NSString *txnid = [NSString stringWithFormat:@"txnid=%@",[paymentServerData valueForKey:@"txnid"]];
NSString *productinfo =[NSString stringWithFormat:@"productinfo=%@",[paymentServerData valueForKey:@"txnid"]];
NSArray *arrayString = [[NSArray alloc] initWithObjects phone, key,furl,txnid,productinfoEncode,nil];
NSString *postString = [arrayString componentsJoinedByString:@"&"];
NSString *address = @"https://secure.payu.in/_payment";
NSURL *url = [NSURL URLWithString: address];
NSString *body = [NSString stringWithFormat: @"%@", postString];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: body];
[_paymentWebView loadRequest: request];
我有5个参数来传递正文字符串,但我想只编码一个参数如何编码一个参数并发送正文方法。
帮我编码 productionfo 字符串。
答案 0 :(得分:0)
// this line for encoding your data .
NSData *postData = [productinfo dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSURL *url = [NSURL URLWithString:@"URL"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:postData];