帮助与文档

> >

一、授权并关注指定微博

关注指定用户,其调用方式如下:

 
方式一,使用全局,在初始化方法里加上如下接口:

            [appInfo SSDKSetAuthSettings:@[@"follow_app_official_microblog"]];
            [appInfo SSDKSetupSinaWeiboByAppKey:MOBSSDKSinaWeiboAppKey
                                      appSecret:MOBSSDKSinaWeiboAppSecret
                                    redirectUri:MOBSSDKSinaWeiboRedirectUri
                                       authType:MOBSSDKSinaWeiboAuthType];


方式二,调用授权登录的方法时设置,如下:
 /**
   *  分享平台授权
   *
   *  @param platformType       平台类型
   *  @param @param settings    授权设置,目前只接受SSDKAuthSettingKeyScopes  属性设置,如:@{SSDKAuthSettingKeyScopes : @[@"all", @"mail"]}
   *  @param stateChangeHandler 授权状态变更回调处理
   */
  + (void)authorize:(SSDKPlatformType)platformType
           settings:(NSDictionary *)settings
     onStateChanged:(SSDKAuthorizeStateChangedHandler)stateChangedHandler ;

  //以新浪微博为例子,在客户端授权时有效,网页授权无效,另外如果用户已经关注了,那么客户端授权时那个关注选项是会被隐藏掉的
      [ShareSDK authorize:SSDKPlatformTypeSinaWeibo settings: @{SSDKAuthSettingKeyScopes : @[@"follow_app_official_microblog"]} onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
          // 处理回调
      }];
需要注意的是:如果已经关注过,第二次是不会继续显示关注选项的;在微博上注册的应用的Bundle id要填写的跟自己项目里的一致。

 二、获取好友功能

#import <ShareSDKExtension/ShareSDK+Extension.h> 
#import <ShareSDKExtension/SSDKFriendsPaging.h>
[ShareSDK getFriends:SSDKPlatformTypeSinaWeibo cursor:0 size:20 onStateChanged:^(SSDKResponseState state, SSDKFriendsPaging *paging, NSError *error) {
        if (state == SSDKResponseStateSuccess) {
            
            NSLog(@"%@",[paging users]);
         
        }
        if (state == SSDKResponseStateFail) {
            NSLog(@"%@",[error description]);
        }
    }];



相关文档