用接口注册账号

- (IBAction)register:(id)sender {
RequestHttpsClass *request = [[RequestHttpsClass alloc] initWithURL:[NSURL URLWithString:@"https://chanyouji.com/api/users.json"]];
request.HTTPMethod = @"POST";
NSString *str = [NSString stringWithFormat:@"email=%@&password=%@", self.users.text, self.passward.text];
request.HTTPBody = [str dataUsingEncoding:NSUTF8StringEncoding];
request.block = ^(NSData *data) {

NSLog(@"%@", [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableLeaves) error:nil]);
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"users" object:nil userInfo:@{@"users":[NSString stringWithFormat:@"%@", self.users.text]}];
}];
};
[request startAsync];
}

posted @ 2015-12-10 22:18  HSX  阅读(252)  评论(0编辑  收藏  举报