Commit 7b4bad173d5c54dcdd6c5b7d02f358a7c55f243e
1 parent
f4b838c0
no message
Showing
8 changed files
with
137 additions
and
3 deletions
CNLiveUserSystemDemo/CNLiveUserSystemSDK/CNLiveUploadIcon.h
| ... | ... | @@ -13,4 +13,7 @@ |
| 13 | 13 | |
| 14 | 14 | - (void)uploadIconWithAppId:(NSString *)appId uid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token secret:(NSString *)secret success:(void (^)(id))success failure:(void (^)(NSDictionary *errorDic))failure; |
| 15 | 15 | |
| 16 | +//图片压缩质量compressionQuality 0-1 Default 0.5 | |
| 17 | +- (void)uploadIconWithAppId:(NSString *)appId uid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token compressionQuality:(CGFloat)compressionQuality secret:(NSString *)secret success:(void (^)(id))success failure:(void (^)(NSDictionary *errorDic))failure; | |
| 18 | + | |
| 16 | 19 | @end | ... | ... |
CNLiveUserSystemDemo/CNLiveUserSystemSDK/CNLiveUploadIcon.m
| ... | ... | @@ -26,6 +26,11 @@ static NSString *uploadIconFormalURL = @"https://api.cnlive.com/open/api2/user/ |
| 26 | 26 | [self getAccessTokenRequestWithAppId:appId uid:uid icon:image token:token secret:secret success:success failure:failure]; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | +- (void)uploadIconWithAppId:(NSString *)appId uid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token compressionQuality:(CGFloat)compressionQuality secret:(NSString *)secret success:(void (^)(id))success failure:(void (^)(NSDictionary *errorDic))failure | |
| 30 | +{ | |
| 31 | + [self getAccessTokenRequestWithAppId:appId uid:uid icon:image token:token compressionQuality:compressionQuality secret:secret success:success failure:failure]; | |
| 32 | +} | |
| 33 | + | |
| 29 | 34 | #pragma mark - request |
| 30 | 35 | |
| 31 | 36 | - (void)getAccessTokenRequestWithAppId:(NSString *)appId uid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token secret:(NSString *)secret success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure |
| ... | ... | @@ -119,4 +124,100 @@ static NSString *uploadIconFormalURL = @"https://api.cnlive.com/open/api2/user/ |
| 119 | 124 | }]; |
| 120 | 125 | } |
| 121 | 126 | |
| 127 | +#pragma mark - 18-4-11 新增 icon可选质量 | |
| 128 | +- (void)getAccessTokenRequestWithAppId:(NSString *)appId uid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token compressionQuality:(CGFloat)compressionQuality secret:(NSString *)secret success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure | |
| 129 | +{ | |
| 130 | + NSDictionary *paramters = @{@"appId":[CNLiveUserSystemTools verify:appId], | |
| 131 | + @"secret":[CNLiveUserSystemTools verify:secret]}; | |
| 132 | + | |
| 133 | + NSString *url; | |
| 134 | + if ([CNLiveUserSystemTools isTestEnvironment]) { | |
| 135 | + url = accessTokenTestURL; | |
| 136 | + } else { | |
| 137 | + url = accessTokenFormalURL; | |
| 138 | + } | |
| 139 | + [[CNLiveUserNetworkManager manager] requestPostURL:url parameters:paramters success:^(NSURLResponse * _Nullable response, id _Nullable responseObject) { | |
| 140 | + | |
| 141 | + responseObject = [responseObject validatedDictionary]; | |
| 142 | + | |
| 143 | + if ([[responseObject allKeys] containsObject:@"errorCode"]) { | |
| 144 | + if ([[responseObject objectForKey:@"errorCode"] isEqualToString:@"0"]) { | |
| 145 | + | |
| 146 | + NSDictionary *dic = responseObject[@"data"]; | |
| 147 | + [self uploadIconRequestWithUid:uid icon:image token:token access_token:dic[@"access_token"] compressionQuality:compressionQuality success:success failure:failure]; | |
| 148 | + } else { | |
| 149 | + if (failure) { | |
| 150 | + failure(responseObject); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } else { | |
| 154 | + NSDictionary *errorDic = @{@"errorCode": @"-1", | |
| 155 | + @"errorMessage": @"获取access_token失败"}; | |
| 156 | + | |
| 157 | + if (failure) { | |
| 158 | + failure(errorDic); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + } failure:^(NSURLResponse * _Nullable response, NSError * _Nullable error) { | |
| 163 | + | |
| 164 | + NSDictionary *errorDic = @{@"errorCode": [NSString stringWithFormat:@"%ld", error.code], @"errorMessage": error.localizedDescription}; | |
| 165 | + | |
| 166 | + if (failure) { | |
| 167 | + failure(errorDic); | |
| 168 | + } | |
| 169 | + }]; | |
| 170 | +} | |
| 171 | +- (void)uploadIconRequestWithUid:(NSString *)uid icon:(UIImage *)image token:(NSString *)token access_token:(NSString *)accessToken compressionQuality:(CGFloat)compressionQuality success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure | |
| 172 | +{ | |
| 173 | + NSData *data; | |
| 174 | + if (compressionQuality >= 0 && compressionQuality <= 1) { | |
| 175 | + data = UIImageJPEGRepresentation(image, compressionQuality); | |
| 176 | + }else{ | |
| 177 | + data = UIImageJPEGRepresentation(image, 0.5); | |
| 178 | + } | |
| 179 | + | |
| 180 | + NSDictionary *paramters = @{@"uid":[CNLiveUserSystemTools verify:uid], | |
| 181 | + @"clientPlat":@"i", | |
| 182 | + @"token":[CNLiveUserSystemTools verify:token], | |
| 183 | + @"access_token":[CNLiveUserSystemTools verify:accessToken]}; | |
| 184 | + | |
| 185 | + NSString *url; | |
| 186 | + if ([CNLiveUserSystemTools isTestEnvironment]) { | |
| 187 | + url = uploadIconTestURL; | |
| 188 | + } else { | |
| 189 | + url = uploadIconFormalURL; | |
| 190 | + } | |
| 191 | + [[CNLiveUserNetworkManager manager] uploadImageWithURL:url parameters:paramters imageData:data success:^(NSURLResponse * _Nullable response, id _Nullable responseObject) { | |
| 192 | + | |
| 193 | + responseObject = [responseObject validatedDictionary]; | |
| 194 | + | |
| 195 | + if ([[responseObject allKeys] containsObject:@"errorCode"] && [responseObject[@"errorCode"] isEqualToString:@"0"]) { | |
| 196 | + | |
| 197 | + if (success) { | |
| 198 | + success(responseObject); | |
| 199 | + } | |
| 200 | + | |
| 201 | + } else { | |
| 202 | + | |
| 203 | + if (failure) { | |
| 204 | + failure(responseObject); | |
| 205 | + } | |
| 206 | + | |
| 207 | + [CNLiveUserSystemTools errorStat:responseObject[@"errorMessage"]]; | |
| 208 | + } | |
| 209 | + | |
| 210 | + | |
| 211 | + } failure:^(NSURLResponse * _Nullable response, NSError * _Nullable error) { | |
| 212 | + | |
| 213 | + NSDictionary *errorDic = @{@"errorCode": [NSString stringWithFormat:@"%ld", error.code], @"errorMessage": error.localizedDescription}; | |
| 214 | + | |
| 215 | + if (failure) { | |
| 216 | + failure(errorDic); | |
| 217 | + } | |
| 218 | + | |
| 219 | + [CNLiveUserSystemTools errorStat:error.localizedDescription]; | |
| 220 | + }]; | |
| 221 | +} | |
| 222 | + | |
| 122 | 223 | @end | ... | ... |
CNLiveUserSystemDemo/CNLiveUserSystemSDK/CNLiveUserInfo.m
| ... | ... | @@ -29,7 +29,7 @@ static NSString *updateUserByIdFormalURL = @"https://api.cnlive.com/open/ap |
| 29 | 29 | |
| 30 | 30 | //更新用户附加信息 |
| 31 | 31 | static NSString *updateOtherInfoTestURL = @"http://test.open.cnlive.com/openapi/api2/user/updateUserExtInfo"; |
| 32 | -static NSString *updateOtherInfoFormalURL = @"https://api.cnlive.com/open/api2/user/updateUserExtInfo"; | |
| 32 | +static NSString *updateOtherInfoFormalURL = @"http://172.16.3.67/open/api2/user/updateUserExtInfo";//@"https://api.cnlive.com/open/api2/user/updateUserExtInfo"; | |
| 33 | 33 | |
| 34 | 34 | //修改密码 |
| 35 | 35 | static NSString *updatePwdTestURL = @"http://test.open.cnlive.com/openapi/api2/user/updatePwdByMobile"; | ... | ... |
CNLiveUserSystemDemo/CNLiveUserSystemSDK/CNLiveUserSystemCenter.h
| ... | ... | @@ -153,12 +153,22 @@ |
| 153 | 153 | /** |
| 154 | 154 | @abstract 上传头像 |
| 155 | 155 | @param uid 用户ID |
| 156 | - @param icon 头像 | |
| 156 | + @param icon 头像 (图片质量 0.5) | |
| 157 | 157 | @param success 成功回调 |
| 158 | 158 | @param failure 失败回调 |
| 159 | 159 | */ |
| 160 | 160 | + (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure; |
| 161 | 161 | |
| 162 | +/** | |
| 163 | + @abstract 上传头像 新增 | |
| 164 | + @param uid 用户ID | |
| 165 | + @param compressionQuality 头像质量 0-1 Default 0.5 | |
| 166 | + @param icon 头像 | |
| 167 | + @param success 成功回调 | |
| 168 | + @param failure 失败回调 | |
| 169 | + | |
| 170 | + */ | |
| 171 | ++ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon compressionQuality:(CGFloat)compressionQuality success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure; | |
| 162 | 172 | |
| 163 | 173 | /** |
| 164 | 174 | @abstract 查询用户信息 | ... | ... |
CNLiveUserSystemDemo/CNLiveUserSystemSDK/CNLiveUserSystemCenter.m
| ... | ... | @@ -162,6 +162,16 @@ |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | + * 上传头像 ,可选图片质量 | |
| 166 | + */ | |
| 167 | ++ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon compressionQuality:(CGFloat)compressionQuality success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure | |
| 168 | +{ | |
| 169 | + CNLiveUploadIcon *uplodIcon = [[CNLiveUploadIcon alloc] init]; | |
| 170 | + [uplodIcon uploadIconWithAppId:[CNLiveUserManager manager].appId uid:uid icon:icon token:[[self class] getToken] compressionQuality:compressionQuality secret:[CNLiveUserManager manager].appSecret success:success failure:failure]; | |
| 171 | +} | |
| 172 | + | |
| 173 | + | |
| 174 | +/** | |
| 165 | 175 | * 查询用户信息 |
| 166 | 176 | */ |
| 167 | 177 | + (void)queryUserInfoWithUid:(NSString *)uid srcUid:(NSString *)srcUid success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure | ... | ... |
Products/CNLiveUserSystemSDK.framework/CNLiveUserSystemSDK
No preview for this file type
Products/CNLiveUserSystemSDK.framework/Headers/CNLiveUserSystemCenter.h
| ... | ... | @@ -153,12 +153,22 @@ |
| 153 | 153 | /** |
| 154 | 154 | @abstract 上传头像 |
| 155 | 155 | @param uid 用户ID |
| 156 | - @param icon 头像 | |
| 156 | + @param icon 头像 (图片质量 0.5) | |
| 157 | 157 | @param success 成功回调 |
| 158 | 158 | @param failure 失败回调 |
| 159 | 159 | */ |
| 160 | 160 | + (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure; |
| 161 | 161 | |
| 162 | +/** | |
| 163 | + @abstract 上传头像 新增 | |
| 164 | + @param uid 用户ID | |
| 165 | + @param compressionQuality 头像质量 0-1 Default 0.5 | |
| 166 | + @param icon 头像 | |
| 167 | + @param success 成功回调 | |
| 168 | + @param failure 失败回调 | |
| 169 | + | |
| 170 | + */ | |
| 171 | ++ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon compressionQuality:(CGFloat)compressionQuality success:(void (^)(id))success failure:(void (^)(NSDictionary *))failure; | |
| 162 | 172 | |
| 163 | 173 | /** |
| 164 | 174 | @abstract 查询用户信息 | ... | ... |
Products/CNLiveUserSystemSDK.framework/Info.plist
No preview for this file type