NSURL *url =
[NSURL URLWithString:@"http://192.168.0.196:8088/zjt_frameesb/api/info"];
NSDictionary
*dic = [[NSDictionary alloc]
initWithObjectsAndKeys:
@"c30e1a88-bab8-4296-a128-23c12476ee2f",@"typeid",
@"b0ffd1414d78752b7591a0a6f4543ee8",@"applycode",
nil];
NSDictionary
*sendDic = [[NSDictionary alloc]
initWithObjectsAndKeys:
dic,@"data",
@"b0ffd1414d78752b7591a0a6f4543ee8",@"system",
@"zjt_content",@"method",
@"ios",@"source",
nil];
NSData
*data = [NSJSONSerialization dataWithJSONObject:sendDic options:NSJSONWritingPrettyPrinted error:nil];
NSString
*jsonString = [[NSString alloc]
initWithData:data encoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request
setHTTPMethod:@"POST"];
NSString
*body = [[NSString
stringWithFormat:@"data="]
stringByAppendingString:jsonString];
NSLog(@"\n%@",body);
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
NSOperationQueue *queue
= [[NSOperationQueue alloc] init];
[request setTimeoutInterval:100.0];
[NSURLConnection
sendAsynchronousRequest:request
queue:queue
completionHandler:^(NSURLResponse *response, NSData
*data, NSError *error){
if
(error) {
NSLog(@"Httperror:%@%d", error.localizedDescription,error.code);
}else{
NSInteger responseCode =
[(NSHTTPURLResponse *)response statusCode];
NSString *responseString
= [[NSString alloc]
initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"HttpResponseCode:%d", responseCode);
NSLog(@"接受加密数据 %@",responseString);
NSString *decodeUrl =
[responseString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"解密数据:%@",decodeUrl);
NSString *encodeUrl =
[decodeUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"加密数据:%@",encodeUrl);
}
}];