MLWeiboUtils Class Reference

Inherits from NSObject
Declared in MLWeiboUtils.h

Overview

Provides utility functions for working with Weibo in a MaxLeap application.

This class is currently for iOS only.

Interacting With Weibo

+ initializeWeiboWithAppKey:redirectURI:

Initializes MaxLeap Weibo Utils.

+ (BOOL)initializeWeiboWithAppKey:(NSString *)appKey redirectURI:(NSString *)redirectURI

Parameters

appKey

Your weibo app key.

redirectURI

@see WBAuthorizeRequest.redirectURI in WeiboSDK.h

Return Value

Return the value returned by [WeiboSDK regiterAppKey:]

Discussion

Warning: You must invoke this in order to use the Weibo functionality in MaxLeap.

Warning: The apis below are only available when [WeiboSDK regiterAppKey:] successfully.

Declared In

MLWeiboUtils.h

Logging In

+ loginInBackgroundWithScope:block:

Asynchronously logs in a user using Weibo with scopes.

+ (void)loginInBackgroundWithScope:(NSString *)scope block:(MLUserResultBlock)block

Parameters

scope

The API scopes requested by the app in a list of comma-delimited, case sensitive strings. http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope

block

The block to execute when the log in completes. It should have the following signature: ^(MLUser *user, NSError *error).

Discussion

This method delegates to the Weibo SDK to authenticate the user, and then automatically logs in (or creates, in the case where it is a new user) a MLUser. The didReceiveWeiboResponse: method defined in WeiboSDKDelegate should be implemented and call [MLWeiboUtils handleAuthorizeResponse:] when the delegate receive WBAuthorizeResponse.

Declared In

MLWeiboUtils.h

+ handleAuthorizeResponse:

Handle the weibo authenticate response to complete the login process.

+ (void)handleAuthorizeResponse:(WBAuthorizeResponse *)authorizeResponse

Parameters

authorizeResponse

The authenticate response received by WeiboSDKDelegate.

Discussion

This method result in a MLUser logging in or creating. And then the block in methocd loginInBackgroundWithScope:block: will be excuted on main thread.

Declared In

MLWeiboUtils.h

+ loginInBackgroundWithAccessToken:block:

Logs in a user using weibo. Allows you to handle user login to weibo, then provide authentication data to log in (or create, in the case where it is a new user) the MLUser.

+ (void)loginInBackgroundWithAccessToken:(MLWeiboAccessToken *)token block:(MLUserResultBlock)block

Parameters

token

The weibo authentication data.

block

The block to execute. The block should have the following argument signature: (MLUser user, NSError error)

Declared In

MLWeiboUtils.h

Linking Users

+ linkUserInBackground:withScope:block:

Asynchronously links weibo with scopes to an existing MLUser.

+ (void)linkUserInBackground:(MLUser *)user withScope:(NSString *)scope block:(MLBooleanResultBlock)block

Parameters

user

User to link with weibo.

scope

The API scopes requested by the app in a list of comma-delimited, case sensitive strings. http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope

block

The block to execute when the linking completes. It should have the following signature: ^(BOOL succeeded, NSError *error).

Discussion

This method delegates to the Weibo SDK to authenticate the user, and then automatically links the account to the MLUser. It will also save any unsaved changes that were made to the user.

Declared In

MLWeiboUtils.h

+ linkUserInBackground:withAccessToken:block:

Asynchronously links Weibo with weibo authentication data to an existing MLUser.

+ (void)linkUserInBackground:(MLUser *)user withAccessToken:(MLWeiboAccessToken *)token block:(MLBooleanResultBlock)block

Parameters

user

User to link with weibo

token

The weibo authentication data

block

The block to execute when the linking completes. It should have the following signature: ^(BOOL succeeded, NSError *error).

Declared In

MLWeiboUtils.h

+ unlinkUserInBackground:block:

Unlinks the MLUser from a Weibo account asynchronously.

+ (void)unlinkUserInBackground:(MLUser *)user block:(MLBooleanResultBlock)block

Parameters

user

User to unlink from weibo.

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

MLWeiboUtils.h

Getting Linked State

+ isLinkedWithUser:

Whether the user has their account linked to weibo.

+ (BOOL)isLinkedWithUser:(MLUser *)user

Parameters

user

User to check for a weibo link. The user must be logged in on this device.

Return Value

YES if the user has their account linked to weibo, otherwise NO.

Declared In

MLWeiboUtils.h