NSString *myLicense = @"901104470713276";//[[NSUserDefaults standardUserDefaults] objectForKey:MY_LICENSE];
NSString *api = [APITools getAPIAddressFor:APIMethodFirstViewDate];
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:
myLicense, @"license",
nil];
ASIFormDataRequest *_request = [APITools getASIHTTPFormDataRequestWithURL:api
params:params];
__weak ASIHTTPRequest *request = _request;
[request setCompletionBlock:^{
NSString *responseString = request.responseString;
NSDictionary *responseDict = [responseString objectFromJSONString]; //json数据转换为字典类型
NSLog(@"服务器返回的结果: %@", responseDict);
if ([responseDict isKindOfClass:[NSDictionary class]]) //如果返回的是字典类型
{
NSLog(@"成功得到字典数据");
if ([[responseDict objectForKey:@"status"] integerValue] == 1) //服务器返回了请求内容
{
[APITools showAlert:@"提示" message:@"注册成功"];
}
else
{
[APITools showAlert:@"提示" message:[responseDict objectForKey:@"message"]];
}
}
else //服务器返回数据不为字典数据
{
[APITools showAlert:@"提示" message:@"服务器返回数据错误"];
}
}];
[request setFailedBlock:^{
dispatch_async(dispatch_get_main_queue(), ^{
[APITools showAlert:@"提示" message:@"请求失败,请稍后重试!"]; //请求失败
});
}];
[request startAsynchronous];
//先标记
使用AsiHttp 提交 json数据
最新推荐文章于 2021-07-17 09:08:42 发布