add weixinapi
This commit is contained in:
@@ -12,4 +12,6 @@
|
||||
+(GiGaNetManager *)shareInstance;
|
||||
+(void)request:(GiGaAPIRequest*)api;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -67,4 +67,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// WeiIXinApiManager.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/27.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface WeiIXinApiManager : NSObject
|
||||
|
||||
/**
|
||||
微信授权成功后获取 access_token
|
||||
|
||||
@param url get access_token
|
||||
@param parameters 参数
|
||||
@param success 成功
|
||||
@param failure 失败
|
||||
*/
|
||||
+(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success
|
||||
failure:(void (^)(NSError *err))failure;
|
||||
|
||||
/**
|
||||
获取微信用户信息
|
||||
|
||||
@param parameters 参数
|
||||
@param success 成功
|
||||
@param failure 失败
|
||||
*/
|
||||
+(void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters
|
||||
success:(void (^)(id response))success
|
||||
failure:(void (^)(NSError *err))failure;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// WeiIXinApiManager.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/27.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WeiIXinApiManager.h"
|
||||
|
||||
@implementation WeiIXinApiManager
|
||||
|
||||
+(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success
|
||||
failure:(void (^)(NSError *err))failure
|
||||
{
|
||||
[self getrequstweiAPiUrl:url params:parameters success:success failure:failure];
|
||||
}
|
||||
|
||||
+ (void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id))success failure:(void (^)(NSError *))failure
|
||||
{
|
||||
[self getrequstweiAPiUrl:url params:parameters success:success failure:failure];
|
||||
|
||||
}
|
||||
|
||||
+(void)getrequstweiAPiUrl:(NSString *)url params:(NSDictionary *)parameters success:(void (^)(id response))success
|
||||
failure:(void (^)(NSError *err))failure
|
||||
{
|
||||
AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init];
|
||||
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
||||
[manager GET:url parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
|
||||
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
if (success) {
|
||||
success(responseObject);
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
if (failure) {
|
||||
failure(error);
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user