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]; }];