LazyNetForIOS
[[LazyHttpClient getInstance] updateBaseUrl:url]; 或者 HttpClient *httpClient=[[HttpClient alloc]initWithBaseUrl:url]; 或者 HttpClient *httpClient=[[HttpClient alloc]init]; [httpClient updateBaseUrl:url];
RequestParam* param=[[RequestParam alloc]initWithUrl:@"/mobile/get"]; [param addBody:self.phoneText.text withKey:@"phone"]; [param addBody:@"158e0590ea4e597836384817ee4108f3" withKey:@"key"]; [[LazyHttpClient getInstance]GET_JSON:self param:param responseClazz:[GetPhoneProvinceResponseModel class] loadingDelegate:nil loadCache:nil success:^(NSString *requestId, id response) { GetPhoneProvinceResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } fail:^(NSString *requestId, NSInteger *errorCode, NSString *errorMsaaege) { self.lable.text=[NSString stringWithFormat:@"获取手机号归属地错误,错误缘由:%@",errorMsaaege]; }];
* 带缓存功能请求(缓存类型有四种,代码中自行查看)
RequestParam* param=[[RequestParam alloc]initWithUrl:@"/mobile/get"]; [param addBody:self.phoneText.text withKey:@"phone"]; [param addBody:@"158e0590ea4e597836384817ee4108f3" withKey:@"key"]; param.cacheLoadType=USE_CACHE_UPDATE_CACHE; [[LazyHttpClient getInstance]GET_JSON:self param:param responseClazz:[GetPhoneProvinceResponseModel class] loadingDelegate:nil loadCache:^(NSString *requestId, id response) { GetPhoneProvinceResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } success:^(NSString *requestId, id response) { GetPhoneProvinceResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } fail:^(NSString *requestId, NSInteger *errorCode, NSString *errorMsaaege) { self.lable.text=[NSString stringWithFormat:@"获取手机号归属地错误,错误缘由:%@",errorMsaaege]; }];
NSString*theUrl=@"/qqevaluate/qq"; RequestParam* param=[[RequestParam alloc]initWithUrl:theUrl]; [param addBody:self.phoneText.text withKey:@"qq"]; [param addBody:@"780e8bced58c6203140b858d7aa2644c" withKey:@"key"]; [[LazyHttpClient getInstance]POST_JSON:self param:param responseClazz:[QQXiongJIResponseModel class] loadingDelegate:nil loadCache:nil success:^(NSString *requestId, id response) { QQXiongJIResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } fail:^(NSString *requestId, NSInteger *errorCode, NSString *errorMsaaege) { self.lable.text=[NSString stringWithFormat:@"调用QQ测凶吉接口错误,错误缘由:%@",errorMsaaege]; }];
* 带缓存功能的(缓存类型有四种,代码中自行查看)
NSString*theUrl=@"/qqevaluate/qq"; RequestParam* param=[[RequestParam alloc]initWithUrl:theUrl]; [param addBody:self.phoneText.text withKey:@"qq"]; [param addBody:@"780e8bced58c6203140b858d7aa2644c" withKey:@"key"]; param.cacheLoadType=USE_CACHE_UPDATE_CACHE; [[LazyHttpClient getInstance]POST_JSON:self param:param responseClazz:[QQXiongJIResponseModel class] loadingDelegate:nil loadCache:^(NSString *requestId, id response) { QQXiongJIResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } success:^(NSString *requestId, id response) { QQXiongJIResponseModel*model=response; self.lable.text=[JSONUtils objectToJSONString:model]; } fail:^(NSString *requestId, NSInteger *errorCode, NSString *errorMsaaege) { self.lable.text=[NSString stringWithFormat:@"调用QQ测凶吉接口错误,错误缘由:%@",errorMsaaege]; }];