mob中ShareSDK分享总结


以微信,微博,QQ为例:分享连接:http://wiki.mob.com/快速集成指南/1: 下载ShareSDK 并导入到工程中2:在AppDelegate.h中进行相应的配置


mob中ShareSDK分享总结_第1张图片

(注释:如果是微博的URL Schemes格式为wb+AppID  微信的就是AppID  已经要注意QQ的格式是QQ+AppID的16进制)

3.代码注册

#pragma mark=====分享

-(void)shareSDKRequest{  

[ShareSDK registerApp:@"836cd76e3f18"];//字符串api20为您的ShareSDK的AppKey     

  //添加新浪微博应用 注册网址 http://open.weibo.com 

  [ShareSDK connectSinaWeiboWithAppKey:@"3984422795"                              appSecret:@"d6d619fe4f30cc41023a747b9376e581"                            redirectUri:@"http://www.sharesdk.cn"];   

//添加QQ应用  注册网址  http://mobile.qq.com/api/  六十进制为 41D5A2C9 

  [ShareSDK connectQQWithQZoneAppKey:@"1104519881"      qqApiInterfaceCls:[QQApiInterface class]                      tencentOAuthCls:[TencentOAuth class]]; 

  //添加微信应用  http://open.weixin.qq.com   

[ShareSDK connectWeChatWithAppId:@"wxf5f94e45ff12229b"                          appSecret:@"21dea7739efd236a5f6f7ea34b6a1c84"     wechatCls:[WXApi class]];

}

4:实现的过程(此处是自定的UI分享界面)效果图如下:


mob中ShareSDK分享总结_第2张图片

-(void)shareEvent:(UIButton*)sender{      

if(sender.tag==100){      

[self shareSDKDemo:ShareTypeWeixiSession];  

}else if (sender.tag==101){      

//QQ        [self shareSDKDemo: ShareTypeQQ];   

}else{       

//weibo        [self shareSDKDemo:ShareTypeSinaWeibo];  

}  

[_shareBgView removeFromSuperview]; 

  [_shareView removeFromSuperview];

}

具体调用的方法

-(void)shareSDKDemo:(ShareType)type {   

//新闻的连接拼接

  [NSString stringWithFormat:@"http://120.26.111.132:8090/wh/pages/mobile/article.jsp?aid=%d",2]

  if (self.newsTypeSign==50) {       

self.newsPath=[NSString stringWithFormat:@"http://120.26.111.132:8090/wh/pages/mobile/article.jsp?bid=%ld",(long)self.bannerId];   

}else{      

self.newsPath=[NSString stringWithFormat:@"http://120.26.111.132:8090/wh/pages/mobile/article.jsp?aid=%ld",(long)self.arctiveId];   

}   

idpublishContent = [ShareSDK content:self.titleName                                      defaultContent:@"haha"      image:[ShareSDK imageWithUrl:self.thumbpath]     title:self.titleName      url:self.newsPath     description:@"zhong"                                            mediaType:SSPublishContentMediaTypeNews];      

//创建弹出菜单容器   

idcontainer = [ShareSDK container];    [container setIPadContainerWithView:self.view arrowDirect:UIPopoverArrowDirectionUp]; 

  //分享 客户端分享 

  [ShareSDK showShareViewWithType:type container:container content:publishContent statusBarTips:YES authOptions:nil shareOptions:nil result:^(ShareType type, SSResponseState state, idstatusInfo, iderror, BOOL end) {      

if (state == SSPublishContentStateSuccess)        {        

  [self showStringHUD:@"分享成功" second:1];     

  }    else if (state == SSPublishContentStateFail)        {         

  NSLog(@"分享失败,错误码:%ld,错误描述:%@", (long)[error errorCode], [error errorDescription]);   

    }    }];}

如果是调用的是调用系统的UI界面   

//创建自定义分享列表   

NSArray *shareList = [ShareSDK customShareListWithType: sinaItem,    tencentItem,                          [NSNumber numberWithInteger:ShareTypeWeixiSession],    [NSNumber numberWithInteger:ShareTypeWeixiTimeline],   [NSNumber numberWithInteger:ShareTypeQQ],                          [NSNumber numberWithInteger:ShareTypeQQSpace],     nil]; 

  //分享接口   

[ShareSDK showShareActionSheet:container    shareList:shareList      content:publishContent                    statusBarTips:YES      authOptions:nil     shareOptions:nil   result:^(ShareType type, SSResponseState state, idstatusInfo, iderror, BOOL end) {

if (state == SSPublishContentStateSuccess){

NSLog(@"发表成功");

}else if (state == SSPublishContentStateFail){

NSLog (@"发布失败!error code == %ld, error code == %@", (long)[error errorCode], [error errorDescription]);

}

}];

你可能感兴趣的:(mob中ShareSDK分享总结)