| | |
| | | #import <CommonCrypto/CommonDigest.h> |
| | | #import "AFNetworking.h" |
| | | |
| | | #define TestRequestHttpsHost @"https://test-gz.hdlcontrol.com" |
| | | #pragma mark API |
| | | #define API_POST_EZ_AddDevice @"/home-wisdom/platform/childAddDevice" |
| | | #define API_POST_EZ_GetChildToken @"/home-wisdom/platform/childToken" |
| | |
| | | * @param verifyCode 设备验证码 |
| | | * @param completion 回调block,error为空时表示添加成功 |
| | | * |
| | | * @return operation |
| | | */ |
| | | + (void)addDeviceByHDL:(NSString *)deviceSerial |
| | | verifyCode:(NSString *)verifyCode |
| | |
| | | * @param deviceSerial 设备序列号 |
| | | * @param completion 回调block,error为空时表示添加成功 |
| | | * |
| | | * @return operation |
| | | */ |
| | | + (void)deleteDeviceByHDL:(NSString *)deviceSerial completion:(void (^)(ResponseData *responseData))completion{ |
| | | //1.设置请求参数 |
| | |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | |
| | | //1,创建你得请求url |
| | | NSString *URL = @""; |
| | | if([GlobalKit shareKit].GlobalRequestHttpsHost == NULL){ |
| | | URL = @"https://test-gz.hdlcontrol.com"; |
| | | NSString *URL = [GlobalKit shareKit].GlobalRequestHttpsHost; |
| | | if([self stringIsNullOrEmpty:URL]){ |
| | | URL = TestRequestHttpsHost; |
| | | } |
| | | URL = [NSString stringWithFormat:@"%@%@", URL, apiPath]; |
| | | |
| | |
| | | newString = [newString substringToIndex:[newString length] - 1]; |
| | | newString = [newString stringByAppendingString: SECRET_KEY]; |
| | | //2.4 MD5转换+转小写 |
| | | if(newString == nil || newString == NULL){ |
| | | if([self stringIsNullOrEmpty:newString]){ |
| | | newString = @""; |
| | | } |
| | | NSString* signstr = [self signMD5Encrypt:newString]; |
| | | [params setValue:signstr forKey:@"sign"]; |
| | | |
| | | return params; |
| | | } |
| | | |
| | | |
| | | /// 字符串判空 |
| | | /// @param valueStr 传入判断字符 |
| | | + (BOOL)stringIsNullOrEmpty:(NSString *)valueStr |
| | | { |
| | | if((valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0)){ |
| | | return YES; |
| | | }else{ |
| | | return NO; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | /// <param name="valueStr"></param> |
| | | /// <returns></returns> |
| | | +(bool)IfValueNeedSign:(NSString *)valueStr{ |
| | | if (( (valueStr == nil || [valueStr isKindOfClass:[NSNull class]] || valueStr.length == 0))//判空字符 |
| | | if (( [self stringIsNullOrEmpty:valueStr])//判空字符 |
| | | || ([[valueStr substringToIndex:1] isEqual:@"{"])//判断是否为对象 |
| | | || ([[valueStr substringToIndex:1] isEqual:@"["])//判断是否为数组 |
| | | ) { |