新浪微博 SDK,支持 OAuth 2.0 认证,支持 ARC。
Objective-C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
WeiboEngine
WeiboKit
README.md

README.md

WeiboKit 是基于 AFNetworking 做的微博 SDK,OAuth 2.0+ARC. 跟多信息详见 README.


新浪微博 SDK,支持 OAuth 2.0 认证,支持 ARC。基于官方 SDK SinaWeiBoSDK2 修改,WBRequest 直接使用了官方封装,不支持 ARC,在 ARC 下要添加 -fno-objc-arc flag.

使用

  1. WBEngine.m 修改设置 appKey, appSecret, redirectURL. redirectURL 必须和微博应用设置的授权回调页一致。

  2. Code

    [[WBEngine sharedWBEngine] setDelegate:self];
    if ([[WBEngine sharedWBEngine] isLoggedIn]) {
        [[WBEngine sharedWBEngine] loggedInUserInfo];
    } else {
        [[WBEngine sharedWBEngine] logIn];
    }
  3. 实现 delegate:

    #pragma mark - WBEngineDelegate
    - (void)engineDidLogIn
    {
        //login success
    }
    
    - (void)engineDidFailLogInWithError:(NSError *)error
    {
        //login failed.
    }
    
    - (void)engineRequest:(WBRequestType)type didSucceedWithResult:(id)result
    {
        if (WBRequestTypeUsersShow == type) {
            if (result && [result isKindOfClass:[NSDictionary class]]) {
                //...
            }
        }
    }
    
    - (void)engineRequest:(WBRequestType)type didFailWithError:(NSError *)error
    {
        DLog(@"requestType:%d, error: %@", type, [error description]);
    }