例如 我要发送的网站是 http://192.168.63.13:9090/interface/queryVersion
post的字段是
detail={
"deviceSn": "e2132ee45c7b0fa762e4201cbe8b965d",
"deviceType": "1",
"iosVersion": "4.3.2",
"etingFlag": "appstore",
"appVersion": "1.0"
}&v=1.0
那么像这种不标准字段 我如何发送呢? 请高手解答
post的字段是
detail={
"deviceSn": "e2132ee45c7b0fa762e4201cbe8b965d",
"deviceType": "1",
"iosVersion": "4.3.2",
"etingFlag": "appstore",
"appVersion": "1.0"
}&v=1.0
那么像这种不标准字段 我如何发送呢? 请高手解答
解决方案 »
- 日历界面
- 关于定义实例变量的问题
- AudioServicesCreateSystemSoundID在系统静音时都能听得到?
- 谁在IPHONE上做过在线flash播放,格式是H.264,文件为.f4m?
- Split View-Based Appliaction 无法在代码判断屏幕旋转方向
- 自定义uitableviewcell 内部添加控件 坐标错误
- ios代码,如何实现点击一个button让uiview里面的控件消失,请进来看下
- 自适应高度的UITableViewCell
- iOS开发中unrecognized selector sent to instance的问题
- vitamio ffepeg
- 请问:如何调整xcode中加入的控件层次
- iphone在线音频,多路同时播放如何实现
就是在HTTP的body中,放这个数据
[request setPostValue:@"Ben" forKey:@"first_name"];
...
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
之后
[request appendPostData:[你的不标准字段 dataUsingEncoding:NSUTF8StringEncoding]];这里,你的不标准字段必须是一个nsstring,你需要把你这一堆东西:
detail={
"deviceSn": "e2132ee45c7b0fa762e4201cbe8b965d",
"deviceType": "1",
"iosVersion": "4.3.2",
"etingFlag": "appstore",
"appVersion": "1.0"
}&v=1.0
放到一个字符窜里就可以了
NSMutableString *sendStr = [NSMutableString string];
// [sendStr appendFormat:@"detail={"];
// [sendStr appendFormat:@"\"deviceSn\": \"e2132ee45c7b0fa762e4201cbe8b965d\","];
// [sendStr appendFormat:@"\"deviceType\": \"1\","];
// [sendStr appendFormat:@"\"iosVersion\": \"4.3.2\","];
// [sendStr appendFormat:@"\"etingFlag\": \"appstore\","];
// [sendStr appendFormat:@"\"appVersion\": \"1.0\""];
// [sendStr appendFormat:@"}&v=1.0 "];
[sendStr appendFormat:@"detail={\"deviceSn\": \"e2132ee45c7b0fa762e4201cbe8b965d\",\"deviceType\": \"1\",\"iosVersion\": \"4.3.2\",\"etingFlag\": \"appstore\",\"appVersion\": \"1.0\"}&v=1.0"];
NSLog(@"sendStr : %@",sendStr);
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[sendStr dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO]];
[request setRequestMethod:@"POST"]; request.delegate = self;
[request startAsynchronous]; //异步调用
这样调用后 还是错误 但是用别得方式 就可以解析出来
难道是 asihttp 不支持吗?
Form Request 只适合 url encoded 类型的数据。