【发布时间】:2016-07-27 05:17:30
【问题描述】:
我有一个 html 页面,点击提交按钮时,我需要调用支付网关 URL。
我正在使用NSMutableURLRequest 并传递了发布数据,我正在使用
调用 URL
请找到以下代码:
NSDictionary *parameters = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:currency_code,apikey,merchant_id,checksum_method,authorize_user,ip_address,hash,NB, nil] forKeys:[NSArray arrayWithObjects:@"currency_code",@"apikey",@"merchant_id",@"checksum_method",@"authorize_user",@"ip_address",@"checksum",@"cardType", nil]];
__block NSString *post = @"";
[parameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([post isEqualToString:@""]) {
post = [NSString stringWithFormat:@"%@=%@",key,obj];
} else {
post = [NSString stringWithFormat:@"%@&%@=%@",post,key,obj];
}
}];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%ld",[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://pay.sandbox.shmart.in/pay_merchant/js"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[webview loadRequest:request];
webViewDidFinishLoad 也被调用,但它向我显示一个空白屏幕。
知道问题出在哪里。
【问题讨论】:
-
尝试在 safari 上点击链接并查看结果
标签: ios objective-c uiwebview