You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weibo/Pods/Weibo_SDK/libWeiboSDK/WBHttpRequest.h

181 lines
5.6 KiB

4 years ago
//
// WBHttpRequest.h
// WeiboSDK
//
// Created by DannionQiu on 14-9-18.
// Copyright (c) 2014年 SINA iOS Team. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#pragma mark - WBHttpRequest and WBHttpRequestDelegate
@class WBHttpRequest;
/**
sdk对于网络请求接口的调用响应 logOutWithToken的请求
*/
@protocol WBHttpRequestDelegate <NSObject>
/**
Http请求的响应
@param response
*/
@optional
- (void)request:(WBHttpRequest *)request didReceiveResponse:(NSURLResponse *)response;
/**
Http请求失败的响应
@param error
*/
@optional
- (void)request:(WBHttpRequest *)request didFailWithError:(NSError *)error;
/**
Http请求的网络返回
@param result
*/
@optional
- (void)request:(WBHttpRequest *)request didFinishLoadingWithResult:(NSString *)result;
/**
Http请求的网络返回
@param data
*/
@optional
- (void)request:(WBHttpRequest *)request didFinishLoadingWithDataResult:(NSData *)data;
/**
SSO授权的重定向
@param URI
*/
@optional
- (void)request:(WBHttpRequest *)request didReciveRedirectResponseWithURI:(NSURL *)redirectUrl;
@end
/**
Http请求的消息结构
*/
@interface WBHttpRequest : NSObject
{
NSURLSessionDataTask *sessionDataTask;
NSMutableData *responseData;
}
/**
URL
*/
@property (nonatomic, strong) NSString *url;
/**
"GET" "POST"
*/
@property (nonatomic, strong) NSString *httpMethod;
/**
*/
@property (nonatomic, strong) NSDictionary *params;
/**
WBHttpRequestDelegate对象SDK对于发起的接口请求的请求的响应
*/
@property (nonatomic, weak) id<WBHttpRequestDelegate> delegate;
/**
TAG
Request
*/
@property (nonatomic, strong) NSString* tag;
/**
HTTP请求接口
HTTP网络请求
@param url url地址
@param httpMethod "GET" "POST"
@param params
@param delegate WBHttpRequestDelegate对象SDK对于发起的接口请求的请求的响应
@param tag TAG,WBHttpRequest实例的tag属性返回
*/
+ (WBHttpRequest *)requestWithURL:(NSString *)url
httpMethod:(NSString *)httpMethod
params:(NSDictionary *)params
delegate:(id<WBHttpRequestDelegate>)delegate
withTag:(NSString *)tag;
/**
Open API HTTP请求接口
HTTP网络请求访open api
@param accessToken accessToken
@param url url地址
@param httpMethod "GET" "POST"
@param params
@param delegate WBHttpRequestDelegate对象SDK对于发起的接口请求的请求的响应
@param tag TAG,WBHttpRequest实例的tag属性返回
*/
+ (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken
url:(NSString *)url
httpMethod:(NSString *)httpMethod
params:(NSDictionary *)params
delegate:(id<WBHttpRequestDelegate>)delegate
withTag:(NSString *)tag;
/**
[WBHttpRequest setDelegate:nil];
使delegate的request方法有效使block的request的网络请求接口
*/
- (void)disconnect;
#pragma mark - block extension
typedef void (^WBRequestHandler)(WBHttpRequest *httpRequest,
id result,
NSError *error);
/**
Open API HTTP请求接口
HTTP网络请求访open api
@param url url地址
@param httpMethod "GET" "POST"
@param params
@param queue NSOperationQueue对象queue为nil,线[NSOperationQueue mainQueue]
@param handler block方法
*/
+ (WBHttpRequest *)requestWithURL:(NSString *)url
httpMethod:(NSString *)httpMethod
params:(NSDictionary *)params
queue:(NSOperationQueue*)queue
withCompletionHandler:(WBRequestHandler)handler;
/**
HTTP请求接口
HTTP网络请求
@param url url地址
@param httpMethod "GET" "POST"
@param params
@param queue NSOperationQueue对象queue为nil,线[NSOperationQueue mainQueue]
@param handler block方法
*/
+ (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken
url:(NSString *)url
httpMethod:(NSString *)httpMethod
params:(NSDictionary *)params
queue:(NSOperationQueue*)queue
withCompletionHandler:(WBRequestHandler)handler;
@end