shareSDK(分享第三方库)的 使用
首先,下载第三方库,可以去官网下载,官网的地址我忘记了,但下面有一个我之前下的和我写的例子,其实官方的例子也写我们只是告诉大家用时需要把哪些代码复制出来就可以用了。
1、导入如下框架和第三方库
新浪微博分享例子下载:http://vdisk.weibo.com/s/BDn59yfnBUifA
下面是微博分享的代码里子:
-(IBAction)shareSina:(id)sender
{
id<ISSPublishContent> publishContent = [ShareSDK publishContent:@"fenxiang"
defaultContent:@""
image:[UIImage imageNamed:@"f"]
imageQuality:0.8
mediaType:SSPublishContentMediaTypeText];
[ShareSDK shareContentWithType:ShareTypeSinaWeibo
content:publishContent
containerController:self
statusBarTips:YES
oneKeyShareList:[NSArray defaultOneKeyShareList]
shareViewStyle:ShareViewStyleDefault
shareViewTitle:@"内容分享"
result:nil];
}
这些代码例子可以在官方提供的例子中找到,官方例子下载地址:
http://vdisk.weibo.com/s/BDn59yfnBUiAb
/**
* @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];
}
}];
}
shareSDK(分享第三方库)的 使用的更多相关文章
- 使用ShareSDK完成第三方(QQ、微信、微博)登录和分享
这几天遇到一个需求:做第三方登录和分享.遇到了一些坑,把整个过程整理记录下来,方便他人,同时也捋一下思路. 当时考虑过把每个平台的SDK下载下来,一个一个弄,一番取舍后决定还是用ShareSDK.这里 ...
- 一个千万量级的APP使用的一些第三方库
转载:http://www.jianshu.com/p/dc8c05cf693d .背景 前段时间在调研第三方推送服务的时候,反编译了一部分市面上比较流行的APP.其中一个无论是在设计还是功能上都堪称 ...
- ios常用的第三方库
ios开发中有可能用到的第三方库进行记录一下: 注:资料信息来源于网络 自己整理 https://developer.apple.com/reference(苹果官方文档) https://gith ...
- ios第三方库和工具类
下面的是使用苹果电脑后,自己的一下积累吧.有好用的第三方库和工具,肯定会第一时间和大家分享的. 自己平时写的一些分类和工具库 SSTools已经在github上面开始更新了,欢迎大家来指正和补充 一. ...
- fir.im Weekly - 热门 iOS 第三方库大盘点
本期 fir.im Weekly 收集的热度资源,大部分关于Android.iOS 开发工具.源码和脑洞大开的 UI 动画,希望给你带来更多的工作创意与灵感. 盘点国内程序员不常用的热门iOS第三方库 ...
- Swift中的Masonry第三方库——SnapKit
在OC开发时我常用一个名叫Masonry的第三方Autolayout库,在转Swift后发现虽然Swift可以混编OC,但总感觉有些麻烦,在Github上发现了这个叫做SnapKit的第三方库,发现使 ...
- 常用iOS第三方库以及XCode插件介绍
第三方库 CocoaPod CocoaPod并不是iOS上的第三方库 而是大名鼎鼎的第三方库的管理工具 在CocoaPod没有出现之前 第三方库的管理是非常痛苦的 尤其是一些大型的库(比如nimbus ...
- Swift中的Masonry第三方库——SnapKit
在OC开发时我常用一个名叫Masonry的第三方Autolayout库,在转Swift后发现虽然Swift可以混编OC,但总感觉有些麻烦,在Github上发现了这个叫做SnapKit的第三方库 ...
- 个人常用iOS第三方库以及XCode插件介绍
第三方库 CocoaPod CocoaPod并不是iOS上的第三方库 而是大名鼎鼎的第三方库的管理工具 在CocoaPod没有出现之前 第三方库的管理是非常痛苦的 尤其是一些大型的库(比如nimbus ...
随机推荐
- 「COCI2016/2017 Contest #2」Bruza
「COCI2016/2017 Contest #2」Bruza 解题思路 : 首先对于任意时刻 \(i\) ,硬币一定移动到了深度为 \(i\) 的节点,所以第 \(i\) 时刻 Danel 一定染掉 ...
- 【离散化】【DFS】Gym - 101617H - Security Badges
题意:给你一张有向图,每条边有个限制范围,只有权值在限制范围内的人能走这条边,问你权值不超过K的人中,有多少人能从S到T. K很大,因此我们只处理边的范围的上下界这O(m)个权值能否到达,以防万一,还 ...
- [CC-STREETTA]The Street
[CC-STREETTA]The Street 题目大意: 给定两个长度为\(n(n\le10^9)\)的数列\(A\)和\(B\),开始数列\(A\)中每一项值为\(-\infty\),数列\(B\ ...
- Mysql插入数据时,报错this is incompatible with sql_mode=only_full_group_by
Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'inform ...
- Velocity模板学习(一)
一.Velocity是什么 Velocity是一个基于Java的模板引擎,允许任何人仅仅简单地使用模板语言就可以引用由Java代码编写的对象. 二.Velocity的基本语法 1.变量 变量的定义 在 ...
- Java高级架构师(一)第41节:Nginx的配置优化以及使用建议
- Maven安装详细图文教程
1.安装maven前需要先安装java,并设置JAVA_HOME环境变量.(详见jdk安装教程) 2. 将apache-maven-3.0.5-bin.zip放到d:\teamwork(自定义目录) ...
- HDU 4704 Sum (2013多校10,1009题)
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
- 关于spring-mvc.xml的mvc:resources元素浅析。
配置如下: <!-- 配置静态资源 --><mvc:resources location="/static/" mapping="/static/**& ...
- 红帽子企业版 7.3 INSTALL SYSTEMTAP
[root@workstation2017 ~]# uname -r 1.安装程序 yum install systemtap systemtap-runtime // 这个会被安装 systemta ...