#import "ViewController.h"
#import "ASIFormDataRequest.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// 1. 创建url
NSURL *url = [NSURL URLWithString:@"http://localhost:8080/MJServer/login"];
// 2. 创建一个请求
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
// 3. 设置多值参数
[request setPostValue:@"123" forKey:@"username"];
[request setPostValue:@"123" forKey:@"pwd"];
// 4. 开始请求
[request startAsynchronous];
// 5. 设置监听方法
__weak typeof (request) weakRequest = request;
[request setCompletionBlock:^{
NSLog(@"请求完毕----%@",[weakRequest responseString]);
}];
}
@end
26>ASI发送post请求
最新推荐文章于 2020-07-06 20:38:48 发布