-
(void)callLoginAPI
{
// 数据加密
CRSA *rsa = [CRSA shareInstance];
_accountEncrypt = [rsa encryptByRsa:self.accountTextField.text];
_passwordEncrypt = [rsa encryptByRsa:self.passwordTextField.text];// 网络请求
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer]; // 重要的设置
// 请求参数
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setValue:_accountEncrypt forKey:@"account"];
[params setValue:_passwordEncrypt forKey:@"password"];[manager POST:BaseURLString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
//返回数据转换(重要) NSString *jsonString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; NSLog(@"------ JSON: ----- %@", jsonString); // UIStoryboard *homePageStoryboard = [UIStoryboard storyboardWithName:@"YXWHomePageViewControllerStoryboard" bundle:nil]; YXWHomePageViewController *hvc = [homePageStoryboard instantiateInitialViewController]; [self.navigationController pushViewController:hvc animated:YES]; [self alertStatus:@"Login success" title:@"Congrats"];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self alertStatus:@"Please enter both Username and Password" title:@"Login Failed !"]; NSLog(@"------- Error ---------: %@", error);
}];
}
AFNetworking “Post” 请求的坑
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- AFURLConnectionOperation 可以说是AFN最基础的类。继承自NSOperation类,将网络...
- AFNetworking请求各种类型的数据备忘笔记 AFNetworking是一个轻量级的iOS网络通信类库。它建...
- 目录一. 用第三方库实现get请求 1. ASI 2. AFNetworking 二. Post请求的实现 1. ...