萤石云 iOSSDK,移植跨平台相关工程
JLChen
2021-07-08 d93de8833865eb833ca72320f317bf92ba2ae52a
Demo/EZOpensdk_iOS_4.15.1_build20201104/Demo/EZOpenSDKDemo/Global/EZHttpUtil.m
@@ -13,9 +13,9 @@
#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"
#define API_POST_EZ_ChildDelDevice @"/home-wisdom/platform/childDelDevice"
#define API_POST_EZ_AddDevice @"/home-wisdom/platform/yingshi/child/addDevice"
#define API_POST_EZ_GetChildToken @"/home-wisdom/platform/yingshi/child/token"
#define API_POST_EZ_ChildDelDevice @"/home-wisdom/platform/yingshi/child/deleteDevice"
#define API_POST_EZ_RefreshToken @"/smart-footstone/member/oauth/login"
@@ -51,13 +51,15 @@
    //2.设置请求参数
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue: [NSString stringWithFormat:@"%d", [GlobalKit shareKit].hdlPlatform] forKey:@"platform"];
    [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"];
    parameters = [self GetSignRequestDictionary:parameters];
    
    [self requestHttpsPost:API_POST_EZ_GetChildToken parameters:parameters completion:^(ResponseData *responseData) {
        if (block) {
            NSString * token = @"";
            if(responseData.success){
                token = responseData.data[@"accessToken"];
//                token = responseData.data[@"accessToken"];
                token = [NSString stringWithFormat:@"%@",responseData.data];
            }
            block(token);
        }
@@ -84,9 +86,11 @@
    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
    [parameters setValue:verifyCode forKey:@"validateCode"];
    [parameters setValue: [NSString stringWithFormat:@"%d",[GlobalKit shareKit].hdlPlatform] forKey:@"platform"];
    [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"];
    parameters = [self GetSignRequestDictionary:parameters];
    
   [self requestHttpsPost:API_POST_EZ_AddDevice parameters:parameters completion:^(ResponseData *responseData) {
    [self requestHttpsPost:API_POST_EZ_AddDevice parameters:parameters completion:^(ResponseData *responseData) {
        if (completion) {
            completion (responseData);
        }
@@ -108,6 +112,8 @@
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
    [parameters setValue: [NSString stringWithFormat:@"%d",[GlobalKit shareKit].hdlPlatform] forKey:@"platform"];
    [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"];
    parameters = [self GetSignRequestDictionary:parameters];
    
    [self requestHttpsPost:API_POST_EZ_ChildDelDevice parameters:parameters completion:^(ResponseData *responseData) {
@@ -251,7 +257,8 @@
    NSString *newString = @"";
    for(NSString *key in sortKeyArray){
        if(params[key] != NULL){
            NSString *valueStr = params[key];
            //Key对应的value强转为NSString
            NSString *valueStr = [NSString stringWithFormat:@"%@",[params objectForKey:key]];
            //检测当前参数是否需要参与校验
            if([self IfValueNeedSign:valueStr]){
                newString = [newString stringByAppendingString:[NSString stringWithFormat:@"%@=%@&", key,valueStr]];
@@ -311,7 +318,10 @@
    if (( [self stringIsNullOrEmpty:valueStr])//判空字符
        || ([[valueStr substringToIndex:1] isEqual:@"{"])//判断是否为对象
        || ([[valueStr substringToIndex:1] isEqual:@"["])//判断是否为数组
        || ([[valueStr substringToIndex:1] isEqual:@"("])//判断是否为数组
        ) {
//        HDLSDKLog(@"不校验: %@",valueStr);
        return false;
    }
    return true;
@@ -319,3 +329,9 @@
@end
#pragma mark - 修改记录
//2021-07-07
//V1.1.3
//1.替换为新接口,根据homeId注册萤石子账号方案。