Latest 0.0.2
Homepage https://github.com/duanruiying/DryWeibo
License MIT
Platforms ios 10.0, requires ARC
Dependencies Weibo_SDK
Frameworks UIKit, Foundation
Authors

iOS: 简化微博集成(授权、获取用户信息、分享)

官网

Prerequisites

  • Xcode 10.2.1
  • iOS 10.0 or later
  • ObjC、Swift

SDK工程配置

全局开放HTTP

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

App工程配置

为URL Types 添加回调scheme(identifier:"com.weibo"、URL Schemes:"wb+AppID")

info.plist文件属性LSApplicationQueriesSchemes中增加如下选项(注意大小写):

sinaweibohd
sinaweibo
weibosdk
weibosdk2.5

全局开放HTTP

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

如果没有“全局开放HTTP”,info.plist文件属性NSAppTransportSecurity需要设置以下白名单:

sina.cn 
weibo.cn 
weibo.com 
sinaimg.cn 
sinajs.cn 
sina.com.cn

格式示例如下:

<key>sina.com.cn</key>
<dict>
    <key>NSIncludesSubdomains</key>
    <true/>
    <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    <true/>
    <key>NSExceptionMinimumTLSVersion</key>
    <string>TLSv1.0</string>
    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
    <false/>
</dict>

Features

SDK配置

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [DryWeibo registerWithAppID:@""
                    redirectURI:@"www.sina.com"
                          scope:@"all"];
    return YES;
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    [DryWeibo handleOpenURL:url];
    return YES;
}

授权、获取用户信息

[DryWeibo auth:^(DryWeiboCode code) {
    NSLog(@"授权状态码: %ld", code);
} successHandler:^(NSString * _Nullable openID, NSString * _Nullable accessToken) {
    NSLog(@"openID: %@, accessToken: %@", openID, accessToken);

    [DryWeibo userWithOpenID:openID accessToken:accessToken errHandler:^(DryWeiboCode code) {
        NSLog(@"用户信息状态码: %ld", code);
    } successHandler:^(NSString * _Nonnull nickName, NSString * _Nonnull headImgUrl) {
        NSLog(@"nickName: %@, headImgUrl: %@", nickName, headImgUrl);
    }];
}];

分享

DryWeiboObj *obj = [[DryWeiboObj alloc] init];
obj.text = @"分享我的测试文本";
[DryWeibo sharedWithType:kDryWeiboObjTypeText message:obj completion:^(DryWeiboCode code) {
    NSLog(@"分享状态码: %ld", code);
}];

Latest podspec

{
    "name": "DryWeibo",
    "version": "0.0.2",
    "summary": "DryWeibo",
    "homepage": "https://github.com/duanruiying/DryWeibo",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "duanruiying": "[email protected]"
    },
    "source": {
        "git": "https://github.com/duanruiying/DryWeibo.git",
        "tag": "0.0.2"
    },
    "description": "TODO: iOSu7b80u5316u5faeu535au96c6u6210(u6388u6743u3001u83b7u53d6u7528u6237u4fe1u606fu3001u5206u4eab).",
    "platforms": {
        "ios": "10.0"
    },
    "requires_arc": true,
    "user_target_xcconfig": {
        "OTHER_LDFLAGS": [
            "-w"
        ]
    },
    "static_framework": true,
    "pod_target_xcconfig": {
        "OTHER_LDFLAGS": [
            "-w",
            "-ObjC"
        ]
    },
    "source_files": "DryWeibo/Classes/Code/**/*",
    "public_header_files": "DryWeibo/Classes/Code/Public/**/*.h",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "dependencies": {
        "Weibo_SDK": [
            "3.2.3"
        ]
    }
}

Pin It on Pinterest

Share This