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.

669 lines
18 KiB

4 years ago
//
// WeiboSDKHeaders.h
// WeiboSDKDemo
//
// Created by Wade Cheng on 4/3/13.
// Copyright (c) 2013 SINA iOS Team. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "WBHttpRequest.h"
typedef NS_ENUM(NSInteger, WeiboSDKResponseStatusCode)
{
WeiboSDKResponseStatusCodeSuccess = 0,//成功
WeiboSDKResponseStatusCodeUserCancel = -1,//用户取消发送
WeiboSDKResponseStatusCodeSentFail = -2,//发送失败
WeiboSDKResponseStatusCodeAuthDeny = -3,//授权失败
WeiboSDKResponseStatusCodeUserCancelInstall = -4,//用户取消安装微博客户端
WeiboSDKResponseStatusCodeShareInSDKFailed = -8,//分享失败 详情见response UserInfo
WeiboSDKResponseStatusCodeUnsupport = -99,//不支持的请求
WeiboSDKResponseStatusCodeUnknown = -100,
};
@protocol WeiboSDKDelegate;
@protocol WBHttpRequestDelegate;
@class WBBaseRequest;
@class WBBaseResponse;
@class WBMessageObject;
@class WBImageObject;
@class WBBaseMediaObject;
@class WBHttpRequest;
@class PHAsset;
@class WBNewVideoObject;
/**
SDK接口类
*/
@interface WeiboSDK : NSObject
/**
@return YESNO
*/
+ (BOOL)isWeiboAppInstalled;
/**
@return 使YES使NO
*/
+ (BOOL)isCanShareInWeiboAPP;
/**
使SSO授权
@return 使YES使NO
*/
+ (BOOL)isCanSSOInWeiboApp;
/**
@return YESNO
*/
+ (BOOL)openWeiboApp;
/**
itunes安装地址
@return itunes安装地址
*/
+ (NSString *)getWeiboAppInstallUrl;
/**
SDK的版本号
@return SDK的版本号
*/
+ (NSString *)getSDKVersion;
extern NSString * const WeiboSDKGetAidSucessNotification;
extern NSString * const WeiboSDKGetAidFailNotification;
/**
SDK的aid
aid值可能为 nil , nil aid
aid SDK会发出名为 WeiboSDKGetAidSucessNotification aid
SDK会发出名为 WeiboSDKGetAidFailNotification NSError
@return aid 广
*/
+ (NSString *)getWeiboAid;
/**
@param appKey appKey
@return YESNO
*/
+ (BOOL)registerApp:(NSString *)appKey;
/**
URL启动第三方应用时传递的数据
application:openURL:sourceApplication:annotation:application:handleOpenURL中调用
@param url URL
@param delegate WeiboSDKDelegate对象
@see WeiboSDKDelegate
*/
+ (BOOL)handleOpenURL:(NSURL *)url delegate:(id<WeiboSDKDelegate>)delegate;
/**
[WeiboSDKDelegate didReceiveWeiboResponse:]
@param request
@see [WeiboSDKDelegate didReceiveWeiboResponse:]
@see WBBaseResponse
*/
+ (BOOL)sendRequest:(WBBaseRequest *)request;
/**
@param response
@see WBBaseRequest
*/
+ (BOOL)sendResponse:(WBBaseResponse *)response;
/**
WeiboSDK的调试模式
WeiboSDK会在控制台输出详细的日志信息 NO
@param enabled WeiboSDK的调试模式
*/
+ (void)enableDebugMode:(BOOL)enabled;
/**
token将失效
@param token Token
@param delegate WBHttpRequestDelegate对象SDK对于发起的接口请求的请求的响应
@param tag TAG,WBHttpRequest实例的tag属性返回
*/
+ (void)logOutWithToken:(NSString *)token delegate:(id<WBHttpRequestDelegate>)delegate withTag:(NSString*)tag;
/**
H5页面SDK自动检测是否安装微博客户端SDK相关方法时
webView H5页面
@param uid id
@param mid id
@param aid id
*/
//连接到指定用户的微博个人主页,连接后可进行加关注等互动
+ (void)linkToUser:(NSString *)uid;
//连接到指定的单条微博详情页,连接后可对这条微博进行转、评、赞等互动
+ (void)linkToSingleBlog:(NSString *)uid blogID:(NSString *)mid;
//连接到指定的微博头条文章页
+ (void)linkToArticle:(NSString *)aid;
//分享到微博
+ (void)shareToWeibo:(NSString *)content;
//评论指定的微博
+ (void)commentToWeibo:(NSString *)mid;
//连接到微博搜索内容流
+ (void)linkToSearch:(NSString *)keyword;
//连接到我的微博消息流
+ (void)linkToTimeLine;
//连接到我的微博个人主页
+ (void)linkToProfile;
@end
/**
*/
@protocol WeiboSDKDelegate <NSObject>
/**
[WeiboSDK sendResponse:]
@param request
*/
- (void)didReceiveWeiboRequest:(WBBaseRequest *)request;
/**
WBBaseResponse.userInfo
@param response
*/
- (void)didReceiveWeiboResponse:(WBBaseResponse *)response;
@end
#pragma mark - DataTransferObject and Base Request/Response
/**
*/
@interface WBDataTransferObject : NSObject
/**
request userInfo
@warning userInfo中的数据必须是实现了 `NSCoding`
@warning 10M
*/
@property (nonatomic, strong) NSDictionary *userInfo;
/**
SDK版本号
sdkVersion为当前SDK的版本号sdkVersion为数据发送方SDK版本号
*/
@property (strong, nonatomic, readonly) NSString *sdkVersion;
/**
YESAlert询问用户是否要打开微博App的安装页面YES
*/
@property (nonatomic, assign) BOOL shouldOpenWeiboAppInstallPageIfNotInstalled;
@end
/**
SDK所有请求类的基类
*/
@interface WBBaseRequest : WBDataTransferObject
/**
WBBaseRequest
@return **WBBaseRequest对象
*/
+ (id)request;
@end
/**
SDK所有响应类的基类
*/
@interface WBBaseResponse : WBDataTransferObject
/**
request
response requestUserInfo request.userInfo
@see WBBaseRequest.userInfo
*/
@property (strong, nonatomic, readonly) NSDictionary *requestUserInfo;
/**
statusCode判断请求的处理结果
*/
@property (nonatomic, assign) WeiboSDKResponseStatusCode statusCode;
/**
WBBaseResponse
@return **WBBaseResponse对象
*/
+ (id)response;
@end
#pragma mark - Authorize Request/Response
/**
[WeiboSDK sendRequest:] WBAuthorizeRequest
WBAuthorizeResponse
*/
@interface WBAuthorizeRequest : WBBaseRequest
/**
`http://`
http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#.E5.AE.A2.E6.88.B7.E7.AB.AF.E9.BB.98.E8.AE.A4.E5.9B.9E.E8.B0.83.E9.A1.B5
@warning `http://`
@warning 1K
*/
@property (nonatomic, strong) NSString *redirectURI;
/**
scopescrope用逗号分隔
http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope
@warning 1K
*/
@property (nonatomic, strong) NSString *scope;
/**
SSO的时候是否弹出SDK自带的Webview进行授权
YESSSO的时候会自动弹出SDK自带的Webview进行授权
NO shouldOpenWeiboAppInstallPageIfNotInstalled /
YES
*/
@property (nonatomic, assign) BOOL shouldShowWebViewForAuthIfCannotSSO;
@end
/**
WBAuthorizeResponse userID accessToken expirationDate refresh_token userInfo
*/
@interface WBAuthorizeResponse : WBBaseResponse
/**
ID
*/
@property (nonatomic, strong) NSString *userID;
/**
*/
@property (nonatomic, strong) NSString *accessToken;
/**
*/
@property (nonatomic, strong) NSDate *expirationDate;
/**
*/
@property (nonatomic, strong) NSString *refreshToken;
@end
#pragma mark - ProvideMessageForWeibo Request/Response
/**
*/
@interface WBProvideMessageForWeiboRequest : WBBaseRequest
@end
/**
*/
@interface WBProvideMessageForWeiboResponse : WBBaseResponse
/**
*/
@property (nonatomic, strong) WBMessageObject *message;
/**
WBProvideMessageForWeiboResponse
@param message
@return **WBProvideMessageForWeiboResponse对象
*/
+ (id)responseWithMessage:(WBMessageObject *)message;
@end
#pragma mark - SendMessageToWeibo Request/Response
/**
*/
@interface WBSendMessageToWeiboRequest : WBBaseRequest
/**
*/
@property (nonatomic, strong) WBMessageObject *message;
/**
WBSendMessageToWeiboRequest
[WeiboSDK sendRequest:]
shouldOpenWeiboAppInstallPageIfNotInstalled /
@param message
@return **WBSendMessageToWeiboRequest对象
*/
+ (id)requestWithMessage:(WBMessageObject *)message;
/**
WBSendMessageToWeiboRequest
,
SDK內微博发布器
@param message
@param authRequest ,access_token二者至少有一个不为空,access_token为空并且需要弹出SDK內发布器时会通过此信息先进行授权后再分享
@param access_token Token,,使token进行分享
@return **WBSendMessageToWeiboRequest对象
*/
+ (id)requestWithMessage:(WBMessageObject *)message
authInfo:(WBAuthorizeRequest *)authRequest
access_token:(NSString *)access_token;
@end
/**
WBSendMessageToWeiboResponse
*/
@interface WBSendMessageToWeiboResponse : WBBaseResponse
/**
*/
@property (nonatomic,strong) WBAuthorizeResponse *authResponse;
@end
#pragma mark - MessageObject / ImageObject
/**
()
*/
@interface WBMessageObject : NSObject
/**
@warning 2000
*/
@property (nonatomic, strong) NSString *text;
/**
@see WBImageObject
*/
@property (nonatomic, strong) WBImageObject *imageObject;
/**
@see WBBaseMediaObject
*/
@property (nonatomic, strong) WBBaseMediaObject *mediaObject;
/**
@see WBVideoObject
*/
@property (nonatomic, strong) WBNewVideoObject *videoObject;
/**
WBMessageObject
@return **WBMessageObject对象
*/
+ (id)message;
@end
/**
*/
typedef NS_ENUM(NSInteger, WBSDKMediaTransferErrorCode)
{
WBSDKMediaTransferAlbumPermissionError = 0,//相册权限
WBSDKMediaTransferAlbumWriteError = 1,//相册写入错误
WBSDKMediaTransferAlbumAssetTypeError = 2,//资源类型错误
};
/**
*/
@protocol WBMediaTransferProtocol <NSObject>
/**
*/
-(void)wbsdk_TransferDidReceiveObject:(id)object;
/**
*/
-(void)wbsdk_TransferDidFailWithErrorCode:(WBSDKMediaTransferErrorCode)errorCode andError:(NSError*)error;
@end
/**
*/
@interface WBImageObject : NSObject
/**
finalAssetArray只能存在一项10M,
使
@warning 10M
*/
@property (nonatomic, strong) NSData *imageData;
/**
story
*/
@property (nonatomic) BOOL isShareToStory;
/**
WBImageObject
@return **WBImageObject对象
*/
+ (id)object;
/**
UIImage
@return **UIImage对象
*/
- (UIImage *)image;
/**
*/
@property(nonatomic,weak)id<WBMediaTransferProtocol> delegate;
/**
*/
- (void)addImages:(NSArray<UIImage *>*)imageArray;
/**
*/
- (void)addImageAssets:(NSArray<PHAsset*>*)assetArray;
/**
*/
-(NSArray*)finalAssetArray;
@end
@interface WBNewVideoObject : NSObject
/**
WBNewVideoObject
@return **WBNewVideoObject对象
*/
+ (id)object;
/**
story
*/
@property (nonatomic) BOOL isShareToStory;
/**
*/
@property(nonatomic,weak)id<WBMediaTransferProtocol> delegate;
/**
*/
-(void)addVideo:(NSURL*)videoUrl;
/**
*/
-(void)addVideoAsset:(PHAsset*)videoAsset;
/**
*/
-(NSString*)finalAsset;
@end
#pragma mark - Message Media Objects
/**
,,linkcard样式,
*/
@interface WBBaseMediaObject : NSObject
/**
ID
@warning 255
*/
@property (nonatomic, strong) NSString *objectID;
/**
@warning 1k
*/
@property (nonatomic, strong) NSString *title;
/**
@warning 1k
*/
@property (nonatomic, strong) NSString *description;
/**
@warning 32k
*/
@property (nonatomic, strong) NSData *thumbnailData;
/**
scheme
@warning 255
*/
@property (nonatomic, strong) NSString *scheme;
/**
WBBaseMediaObject
@return **WBBaseMediaObject对象
*/
+ (id)object;
@end
#pragma mark - Message WebPage Objects
/**
*/
@interface WBWebpageObject : WBBaseMediaObject
/**
url地址
@warning 255
*/
@property (nonatomic, strong) NSString *webpageUrl;
@end