首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

shareSDK(分享第三方库)的 施用

2013-10-08 
shareSDK(分享第三方库)的 使用首先,下载第三方库,可以去官网下载,官网的地址我忘记了,但下面有一个我之前

shareSDK(分享第三方库)的 使用

首先,下载第三方库,可以去官网下载,官网的地址我忘记了,但下面有一个我之前下的和我写的例子,其实官方的例子也写我们只是告诉大家用时需要把哪些代码复制出来就可以用了。


1、导入如下框架和第三方库

shareSDK(分享第三方库)的 施用


新浪微博分享例子下载:http://vdisk.weibo.com/s/BDn59yfnBUifA

下面是微博分享的代码里子:

/** *@brief分享到新浪微博 * *@param sender 事件对象 */- (void)shareToSinaWeiboClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeSinaWeibo                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];    }/** *@brief分享到腾讯微博 * *@param sender 事件对象 */- (void)shareToTencentWeiboClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeTencentWeibo                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享给QQ好友 * *@param sender 事件对象 */- (void)shareToQQFriendClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText                                                              title:@"ShareSDK"                                                                url:@"http://www.sharesdk.cn"                                                       musicFileUrl:nil                                                            extInfo:nil                                                           fileData:nil];    [ShareSDK shareContentWithType:ShareTypeQQ                           content:publishContent               containerController:self                     statusBarTips:NO                   oneKeyShareList:nil                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到QQ空间 * *@param sender 事件对象 */- (void)shareToQQSpaceClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [publishContent addQQSpaceUnitWithTitle:@"Hello QQ空间"                                        url:@"http://www.sharesdk.cn"                                    comment:INHERIT_VALUE                                    summary:CONTENT                                      image:INHERIT_VALUE                               imageQuality:INHERIT_VALUE                                       type:INHERIT_VALUE                                    playUrl:nil                                  syncWeibo:nil];        [ShareSDK shareContentWithType:ShareTypeQQSpace                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享给微信好友 * *@param sender 事件对象 */- (void)shareToWeixinSessionClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText                                                              title:@"ShareSDK"                                                                url:@"http://www.sharesdk.cn"                                                       musicFileUrl:nil                                                            extInfo:nil                                                           fileData:nil];    [ShareSDK shareContentWithType:ShareTypeWeixiSession                           content:publishContent               containerController:self                     statusBarTips:NO                   oneKeyShareList:nil                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享给微信朋友圈 * *@param sender 事件对象 */- (void)shareToWeixinTimelineClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeNews                                                              title:@"ShareSDK"                                                                url:@"http://www.baidu.com"                                                       musicFileUrl:nil                                                            extInfo:nil                                                           fileData:nil];    [ShareSDK shareContentWithType:ShareTypeWeixiTimeline                           content:publishContent               containerController:self                     statusBarTips:YES                          autoAuth:YES                        convertUrl:YES                  shareViewOptions:nil                            result:nil];}/** *@brief分享到网易微博 * *@param sender 事件对象 */- (void)shareTo163WeiboClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareType163Weibo                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到搜狐微博 * *@param sender 事件对象 */- (void)shareToSohuWeiboClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeSohuWeibo                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到人人网 * *@param sender 事件对象 */- (void)shareToRenRenClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];        [ShareSDK shareContentWithType:ShareTypeRenren                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到开心网 * *@param sender 事件对象 */- (void)shareToKaiXinClickHandler:(UIButton *)sender{        id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeKaixin                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到豆瓣我说 * *@param sender 事件对象 */- (void)shareToDouBanClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeDouBan                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到Instapaper * *@param sender 事件对象 */- (void)shareToInstapaperClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeInstapaper                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到Facebook * *@param sender  事件对象 */- (void)shareToFacebookClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];        [ShareSDK shareContentWithType:ShareTypeFacebook                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief分享到Twitter * *@param sender Twitter */- (void)shareToTwitterClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];        [ShareSDK shareContentWithType:ShareTypeTwitter                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:nil];}/** *@brief短信分享 * *@param sender 事件对象 */- (void)shareBySMSClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeSMS                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:^(ShareType type, SSPublishContentState state, id<ISSStatusInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {                                if (state == SSPublishContentStateSuccess)                                {                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"                                                                                        message:@"分享成功"                                                                                       delegate:nil                                                                              cancelButtonTitle:@"知道了"                                                                              otherButtonTitles: nil];                                    [alertView show];                                    [alertView release];                                }                                else if(state == SSPublishContentStateFail)                                {                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"                                                                                        message:error.errorDescription                                                                                       delegate:nil                                                                              cancelButtonTitle:@"知道了"                                                                              otherButtonTitles: nil];                                    [alertView show];                                    [alertView release];                                }                            }];}/** *@brief邮件分享 * *@param sender 事件对象 */- (void)shareByMailClickHandler:(UIButton *)sender{    id<ISSPublishContent> publishContent = [ShareSDK publishContent:CONTENT                                                     defaultContent:@""                                                              image:[UIImage imageNamed:IMAGE_NAME]                                                       imageQuality:0.8                                                          mediaType:SSPublishContentMediaTypeText];    [ShareSDK shareContentWithType:ShareTypeMail                           content:publishContent               containerController:self                     statusBarTips:YES                   oneKeyShareList:[NSArray defaultOneKeyShareList]                    shareViewStyle:ShareViewStyleDefault                    shareViewTitle:@"内容分享"                            result:^(ShareType type, SSPublishContentState state, id<ISSStatusInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {                                if (state == SSPublishContentStateSuccess)                                {                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"                                                                                        message:@"分享成功"                                                                                       delegate:nil                                                                              cancelButtonTitle:@"知道了"                                                                              otherButtonTitles: nil];                                    [alertView show];                                    [alertView release];                                }                                else if(state == SSPublishContentStateFail)                                {                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"                                                                                        message:error.errorDescription                                                                                       delegate:nil                                                                              cancelButtonTitle:@"知道了"                                                                              otherButtonTitles: nil];                                    [alertView show];                                    [alertView release];                                }                            }];}



1楼panjiangfy12045天前 14:09
标题都写错了....shareSDK
Re: qqMCY5天前 16:54
回复panjiangfy1204n感谢提示,改过来了

热点排行