ios HTTP post请求
来源:互联网 发布:冰与火之歌 知乎 编辑:程序博客网 时间:2024/05/21 03:17
NSData *postData = [jsonStringdataUsingEncoding:NSUTF8StringEncodingallowLossyConversion:YES];
NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:[NSURLURLWithString:urlStr]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
NSString* postDataLengthString = [[NSStringalloc] initWithFormat:@"%d", [postDatalength]];
[request setValue:@"application/x-www-form-urlencoded"forHTTPHeaderField:@"Content-Type"];
[request setValue:postDataLengthStringforHTTPHeaderField:@"Content-Length"];
NSError *error =nil;
NSURLResponse *responses;
NSData *data = [NSURLConnectionsendSynchronousRequest:request returningResponse:&responseserror:&error];
NSDictionary *responseDic =nil;
NSDictionary *responseDic = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableLeaveserror:nil];
Content-Type 的类型有多种,在此用到了application/x-www-form-urlencoded,这也是一种默认的类型,大家可以搜一下HTTP的Content-Type类型
- ios HTTP post请求
- IOS开发 HTTP相关GET/POST请求
- ios发送http GET和POST请求
- iOS原生Http请求,get post 异步
- IOS HTTP 之同步请求、异步请求、GET请求、POST请求
- android http post请求
- http的post请求
- C# http post请求
- HTTP 模拟post请求
- http post get 请求
- http请求post
- HTTP GET/POST 请求
- http post get请求
- http post 客户端请求
- HTTP POST 网络请求
- http 原生post 请求
- http post请求
- http请求 get post
- 在Qt中连接SQLite和MySQL数据库
- scanf的用法
- .NET通过RFC读取SAP数据
- Oracle中存储过程和函数的区别
- android让一个activity 浮在锁屏界面的上方
- ios HTTP post请求
- 识海日志——时间都去哪了(201405)
- 【容易打工网】身处职场,如何与知识型老板周旋
- 终于明白了字符串匹配
- oracle教程
- 啊烦死个电饭锅等各方面
- Mac 下数据库MySQL安装
- Geeks Union-Find Algorithm Union By Rank and Path Compression 图环算法
- zip_support/ZipUtils