各种开发平台创建key http://bbs.mob.com/forum.php?mod=viewthread&tid=275&page=1&extra=#pid860
系统库文件
必须添加的依赖库如下:
- SystemConfiguration.framework
- QuartzCore.framework
- CoreTelephony.framework
- libicucore.dylib
- libz.1.2.5.dylib
- Security.framework
以下依赖库根据社交平台添加
新浪微博SDK依赖库 (从v2.10.5开始)
- ImageIO.framework
腾讯微博SDK依赖库
- Social.framework
- Accounts.framework
短信和邮件分享必要
- MessageUI.framework
QQ好友和QQ空间SSO必要(新注册腾讯开放平台帐号只支持SSO授权,只是老开发者才可以使用网页授权)
- libstdc++.dylib
- libsqlite3.dylib
Google+ 分享必要
- CoreMotion.framework
- CoreLocation.framework
- MediaPlayer.framework
- CoreText.framework
- AssetsLibrary.framework
- AddressBook.framework
头文件
#import <ShareSDK/ShareSDK.h>
//第三方平台的SDK头文件,根据需要的平台导入。
//以下分别对应微信、新浪微博、腾讯微博、人人、易信
#import "WXApi.h"
#import "WeiboSDK.h"
#import "WeiboApi.h"
//#import <RennSDK/RennSDK.h>
//#import "YXApi.h"
//以下是腾讯QQ和QQ空间
#import <TencentOpenAPI/QQApi.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
//以下分别是Google+、Pinterest
//#import <GoogleOpenSource/GoogleOpenSource.h>
//#import <GooglePlus/GooglePlus.h>
//#import <Pinterest/Pinterest.h>
//开启QQ和Facebook网页授权需要
#import <QZoneConnection/ISSQZoneApp.h>
//#import <FacebookConnection/ISSFacebookApp.h>
AppDelegate
//第三方分享
[ShareSDKregisterApp:@"5559f92aa230"];
//微博分享 [ShareSDKconnectSinaWeiboWithAppKey:@"568898243"appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"redirectUri:@"http://www.sharesdk.cn"weiboSDKCls:[WeiboSDKclass]];
//短信分享
[ShareSDKconnectSMS];
//连接邮件
[ShareSDKconnectMail];
//连接打印
[ShareSDKconnectAirPrint];
//连接拷贝
[ShareSDKconnectCopy];
//QQ空间
if ([QQApiisQQInstalled]) {
NSLog(@"安装了QQ客户端");
[ShareSDKconnectQZoneWithAppKey:@"100371282"
appSecret:@"aed9b0303e3ed1e27bae87c33761161d"
qqApiInterfaceCls:[QQApiInterfaceclass]
tencentOAuthCls:[TencentOAuthclass]];
}
//微信
[WXApi registerApp:@"wx4868b35061f87885"];
if ([WXApi isWXAppInstalled]) {
NSLog(@"安装了微信");
[ShareSDK connectWeChatWithAppId:@"wx4868b35061f87885" //微信APPID
appSecret:@"64020361b8ec4c99936c0e3999a9f249" //微信APPSecret
wechatCls:[WXApi class]];
}
-(IBAction)shareClick:(id)sender
{
NSString *share_title = @"分享的标题";
NSString *share_url = @"www.分享的网址.com";
NSString *share_content = @"分享的内容";
NSString *file = [[NSStringalloc]initWithFormat:@"SWK/a"];
NSString *imagePath = [[NSBundlemainBundle]pathForResource:fileofType:@"png"];
id<ISSContent> publishContent = [ShareSDKcontent:share_content
defaultContent:share_content
image:[ShareSDKimageWithPath:imagePath]
title:share_title
url:share_url
description:share_content
mediaType:SSPublishContentMediaTypeNews];
[ShareSDKshowShareActionSheet:nil
shareList:nil
content:publishContent
statusBarTips:NO
authOptions:nil
shareOptions: nil
result:^(ShareType type,SSResponseState state,id<ISSPlatformShareInfo> statusInfo,id<ICMErrorInfo> error,BOOL end) {
if (state == SSResponseStateSuccess)
{
if (type ==ShareTypeSinaWeibo) {
NSLog(@"分享成功");
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"恭喜"message:@"分享"delegate:nilcancelButtonTitle:@"Cancel"otherButtonTitles:@"OKay",nil];
[alert show];
}
}else if (state == SSResponseStateFail){
NSString *tt = [NSStringstringWithFormat:@"分享失败,错误码:%ld,错误描述:%@", [error errorCode], [error errorDescription]];
UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"分享失败"message:ttdelegate:nilcancelButtonTitle:@"Cancel"otherButtonTitles:@"OKay",nil];
[alert show];
}
}];
新浪微博中遇到的问题:
}