iOS shareSDK进行分享

各种开发平台创建key    http://bbs.mob.com/forum.php?mod=viewthread&tid=275&page=1&extra=#pid860


系统库文件

必须添加的依赖库如下:

  1. SystemConfiguration.framework
  2. QuartzCore.framework
  3. CoreTelephony.framework
  4. libicucore.dylib
  5. libz.1.2.5.dylib
  6. Security.framework

以下依赖库根据社交平台添加

新浪微博SDK依赖库 (从v2.10.5开始)

  1.  ImageIO.framework

腾讯微博SDK依赖库

  1. Social.framework
  2. Accounts.framework

短信和邮件分享必要

  1. MessageUI.framework

QQ好友和QQ空间SSO必要(新注册腾讯开放平台帐号只支持SSO授权,只是老开发者才可以使用网页授权)

  1. libstdc++.dylib
  2. libsqlite3.dylib

Google+ 分享必要

  1. CoreMotion.framework
  2. CoreLocation.framework
  3. MediaPlayer.framework
  4. CoreText.framework
  5. AssetsLibrary.framework
  6. AddressBook.framework  

头文件

#import <ShareSDK/ShareSDK.h>

//第三方平台的SDK头文件,根据需要的平台导入。

//以下分别对应微信、新浪微博、腾讯微博、人人、易信

#import "WXApi.h"

#import "WeiboSDK.h"

#import "WeiboApi.h"

//#import <RennSDK/RennSDK.h>

//#import "YXApi.h"

//以下是腾讯QQQQ空间

#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>


//开启QQFacebook网页授权需要

#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];

                                }

                            }];



新浪微博中遇到的问题:

}






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值