NSString *postURL = @"http://pay.xxx.com/";
NSURL *url = [NSURL URLWithString:postURL];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10];
[request setHTTPMethod:@"POST"];
NSString *str = [NSString stringWithFormat:@"orderId=%@",self.order_id]; // x=y 的形式
NSLog(@",,,%@",str);
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; // NSString-->NSData
[request setHTTPBody:data];
NSData *received = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil
error:nil]; // connect
// NSData --> NSDictionary
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:received options:NSJSONReadingAllowFragments error:nil];
NSString *__str = [[NSString alloc] initWithData:received encoding:NSUTF8StringEncoding]; // NSDictionary-->NSString
NSLog(@"strings.....%@",__str);
NSString *result = [json objectForKey:@"status"];
if ([result isEqualToString:@"0"]) {
}
objective-c post验证付款信息
最新推荐文章于 2015-07-16 10:20:04 发布