版权声明:转载请申明出处 https://blog.csdn.net/qq_16732587/article/details/86661102
每天积累一点点,以后成就非凡
-(void)post{
// 你要请求的地址
NSURL * url =[NSURL URLWithString:@"https://app.iocydia.com/WxAuthPort/loginPort.do"];
NSMutableURLRequest *req= [NSMutableURLRequest requestWithURL:url];
req.HTTPMethod=@"POST"; //请求方设置为POST ⚠️注意要区分大小写
//请求的参数
req.HTTPBody = [@"username=test&password=123456" dataUsingEncoding:NSUTF8StringEncoding];
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
//请求返回值
NSLog(@"%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
}];
}
终有一天修炼成神!