iOS- 三步快速集成社交化分享工具ShareSDK
http://www.cnblogs.com/qingche/p/3727559.html
1.前言
2.集成前的准备工作
2.1. 拿自己的Appkey 去下载ShareSDK
2.2. 申请分享工具的Appkey
//新浪微博: //App Key:2258477553 //App Secret:1e2f275afc375109e456f550fb3918e8 //腾讯微博: //App key:2620460989 //App secret:58c55f572d5ae35e0c355f4c0ee11283
3.集成ShareSDK
3.1.注册使用ShareSDK
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //注册ShareSDK [ShareSDK registerApp:@"1983bf0916db”]; return YES; }
3.2.添加要集成的分享平台
注意: 新浪微博需要提供回调地址才行
回调地址去新浪开发者平台获取
如图:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //注册ShareSDK [ShareSDK registerApp:@"1983bf0916db”]; //添加新浪微博应用 [ShareSDK connectSinaWeiboWithAppKey:@"2620460989" appSecret:@"58c55f572d5ae35e0c355f4c0ee11283" redirectUri:@"http://weibo.cn/ext/share?ru=http%3A%2F%2F16kxs.com%2Fwap%2FBook%2FShow.aspx%3Fid%3D7983%26lmid%3D0%26uid%3D0%26ups%3D0&rt=%E9%83%BD%E5%B8%82%E7%89%A7%E9%AC%BC%E4%BA%BA&st=1301645308&appkey=2620460989”]; //添加腾讯微博应用 [ShareSDK connectTencentWeiboWithAppKey:@"801307650" appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c" redirectUri:@"http://www.sharesdk.cn"]; //添加豆瓣应用 [ShareSDK connectDoubanWithAppKey:@"07d08fbfc1210e931771af3f43632bb9" appSecret:@"e32896161e72be91" redirectUri:@"http://dev.kumoway.com/braininference/infos.php"]; //添加人人网应用 [ShareSDK connectRenRenWithAppKey:@"fc5b8aed373c4c27a05b712acba0f8c3" appSecret:@"f29df781abdd4f49beca5a2194676ca4"]; //添加Facebook应用 [ShareSDK connectFacebookWithAppKey:@"107704292745179" appSecret:@"38053202e1a5fe26c80c753071f0b573"]; }
3.3.弹出分享View
a.初始化默认分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"123" ofType:@"png"]; //构建优秀的SDK //构造分享内容 id<ISSContent> publishContent = [ShareSDK content:@"iOS社交化分享测试内容。" defaultContent:@"默认分享内容,没内容时显示" image:[ShareSDK imageWithPath:imagePath] title:@"ShareSDK" url:@"http://www.sharesdk.cn" description:@"这是一条测试信息" mediaType:SSPublishContentMediaTypeNews];
b.弹出分享View
[ShareSDK showShareActionSheet:nil shareList:nil content:publishContent statusBarTips:YES authOptions:nil shareOptions: nil result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) { if (state == SSResponseStateSuccess) { NSLog(@"分享成功"); } else if (state == SSResponseStateFail) { NSLog(@"分享失败,错误码:%d,错误描述:%@", [error errorCode], [error errorDescription]); } }];
效果图:
出处: http://www.cnblogs.com/qingche/
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。