http://www.2cto.com/kf/201504/395288.html
/**
- 注册手机号请求
- POST数据示例: {"version":16,"token":"","msgType":"MSG_USER_REGISTER_REQ","msgSeq":207,
- "appType":4,"IMEI":"356199060018702","phoneNo":"18811110000","userName":"cxxxyx18811110000",
- "password":"qwertyuiop","msgCode":"151551"}
*/
-
(void) registerPhoneNo {
User* currentUser = [User currentUser]; // 账号
NSMutableDictionary* paras = [[NSMutableDictionary alloc] init]; // POST参数
[paras setObject:currentUser.matVersion forKey:@"version"]; // 版本号
[paras setObject:(currentUser.matToken == nil)?@"":currentUser.matToken forKey:@"token"]; // Token
[paras setObject:@"MSG_USER_REGISTER_REQ" forKey:@"msgType"]; // 消息类型
[paras setObject:[NSString stringWithFormat:@"%d",currentUser.matMsgSeq] forKey:@"msgSeq"]; // 消息序列
[paras setObject:currentUser.matAppType forKey:@"appType"]; // APP类型
[paras setObject:currentUser.uniqueDeviceToken forKey:@"IMEI"]; // 唯一码
[paras setObject:currentUser.matPhoneNo forKey:@"phoneNo" ]; // 手机号
[paras setObject:[NSString stringWithFormat:@"chunyu%@",currentUser.username] forKey:@"userName"]; // 用户名
[paras setObject:currentUser.matPassword forKey:@"password"]; // 密码
[paras setObject:_activiateCodeTextField.text forKey:@"msgCode"]; // 验证码[输入]NSLog(@"注册手机号参数: %@", paras);
// POST请求: MSG_USER_REGISTER_REQ
[[ChunyuAPIClient sharedClient] postPath:[ChunyuAPIClient MAT_NOAUTH_HTTP_URL]
parameters:paras
requestContentType:kCYHttpRequestContentTypeJSON
success:^(AFHTTPRequestOperation operation, id responseObject) {
NSLog(@"MSG_USER_REGISTER_REQ + %@", responseObject);
NSString loginState = responseObject[@"description"];
NSLog(@"注册状态: %@", loginState);
[SVProgressHUD showErrorWithStatus: loginState duration:2.0f]; // 提示// 登录成功 if ([responseObject[@"errorCode"] intValue] == 0) { [self dismissController]; // 关闭验证页面 } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"请求错误 + %@", error); [SVProgressHUD showErrorWithStatus: @"服务器异常"]; // 提示 }];
}
重置密码请求函数:
与注册手机号请求类型(msgType)不同, 去掉用户名(userName)参数.
/**
- 重置密码请求
- POST数据示例: {"version":16,"token":"","msgType":"MSG_RESET_PASSWORD_REQ","msgSeq":16,
- "appType":4,"IMEI":"356199060018702","phoneNo":"18511452178","password":"qwertyui",
- "msgCode":"545767"}
*/
-
(void) resetPassword {
User* currentUser = [User currentUser]; // 账号
NSMutableDictionary* paras = [[NSMutableDictionary alloc] init]; // POST参数
[paras setObject:currentUser.matVersion forKey:@"version"]; // 版本号
[paras setObject:(currentUser.matToken == nil)?@"":currentUser.matToken forKey:@"token"]; // Token
[paras setObject:@"MSG_RESET_PASSWORD_REQ" forKey:@"msgType"]; // 消息类型
[paras setObject:[NSString stringWithFormat:@"%d",currentUser.matMsgSeq] forKey:@"msgSeq"]; // 消息序列
[paras setObject:currentUser.matAppType forKey:@"appType"]; // APP类型
[paras setObject:currentUser.uniqueDeviceToken forKey:@"IMEI"]; // 唯一码
[paras setObject:currentUser.matPhoneNo forKey:@"phoneNo" ]; // 手机号
[paras setObject:currentUser.matPassword forKey:@"password"]; // 密码
[paras setObject:_activiateCodeTextField.text forKey:@"msgCode"]; // 验证码[输入]NSLog(@"重置密码参数: %@", paras);
// POST请求: MSG_RESET_PASSWORD_REQ
[[ChunyuAPIClient sharedClient] postPath:[ChunyuAPIClient MAT_NOAUTH_HTTP_URL]
parameters:paras
requestContentType:kCYHttpRequestContentTypeJSON
success:^(AFHTTPRequestOperation operation, id responseObject) {
NSLog(@"MSG_RESET_PASSWORD_REQ + %@", responseObject);
NSString loginState = responseObject[@"description"];
NSLog(@"注册状态: %@", loginState);[SVProgressHUD showErrorWithStatus: loginState duration:2.0f]; // 提示 // 登录成功 if ([responseObject[@"errorCode"] intValue] == 0) { [self dismissController]; // 关闭验证页面 } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"responseObject + %@", error); [SVProgressHUD showErrorWithStatus: @"服务器异常"]; // 提示 }];
}