添加空间ShareSDK 微博空间分享

今天朋友几篇文章介绍了改添加空间的文章. 关联文章的地址

    第一步:

    首先导入ShareSDK第三方类库,添加依附框架 :

    

SystemConfiguration.framework

    

QuartzCore.framework

    

MessageUI.framework(如果不集成邮件和短信可以不添加)

    

libicucore.dylib
libz.1.2.5

    

第二步: 导入头文件#import "ShareSDK.h" 并初始化交际平台APP信息。

    

AppDelegate.m文件中

    

-(void)initializePlat{

    //添加新浪微博应用  (其他应用添加方法以此类推)

    [ShareSDKconnectSinaWeiboWithAppKey:@"3201194191"appSecret:@"0334252914651e8f76bad63337b3b78f"redirectUri:@"http://appgo.cn"];

    //添加腾讯微博应用

    [ShareSDKconnectTencentWeiboWithAppKey:@"801307650"appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c"redirectUri:@"http://www.sharesdk.cn"];

    //添加QQ空间应用

    [ShareSDKconnectQZoneWithAppKey:@"100371282"

                           appSecret:@"aed9b0303e3ed1e27bae87c33761161d"];

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加以下代码

 

    //注册SDK

    [ShareSDKregisterApp:@"api20"];

    [ShareSDKconvertUrlEnabled:YES];

    [selfinitializePlat];

第三步: 在一个viewController里头增长一个Button,点击Button开始微博空间分享功能

 

@implementation ViewController


- (void)viewDidLoad

{

    [superviewDidLoad];

UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    button.autoresizingMask =UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;

    [button setTitle:@"分享全体" forState:UIControlStateNormal];

    button.frame =CGRectMake(20,50, 200, 45.0);

    [button addTarget:selfaction:@selector(shareAllButtonClickHandler:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:button];

}

- (void)shareAllButtonClickHandler:(UIButton *)sender{

   NSLog(@"菜单");

    NSString *imagePath =  [[NSBundlemainBundle] pathForResource:@"3"ofType:@"jpg"];

   id<ISSContainer> container = [ShareSDKcontainer];

   id<ISSContent> publishContent = [ShareSDKcontent:@"分享内容"

                                      defaultContent:@"默认分享内容,没内容时显示"

                                               image:[ShareSDKimageWithPath:imagePath]

                                               title:@"ShareSDK"

                                                 url:@"http://www.sharesdk.cn"

                                         description:@"这是一条测试信息"

                                           mediaType:SSPublishContentMediaTypeNews]; //分享内容方式(可选择)

    [ShareSDKshowShareActionSheet:container

                        shareList:nil

                          content:publishContent

                    statusBarTips:YES

                      authOptions:nil

                     shareOptions:nil

                           result:^(ShareType type,SSPublishContentState state, id<ISSStatusInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {

                               if (state == SSPublishContentStateSuccess)

                                {

                                   NSLog(@"分享胜利");

                                }

                               else if (state ==SSPublishContentStateFail)

                                {

                                   NSLog(@"分享失败,错误码:%d,错误描述:%@", [error errorCode], [error errorDescription]);

                                }

                            }];

}


    每日一道理
生命不是一篇"文摘",不接受平淡,只收藏精彩。她是一个完整的过程,是一个"连载",无论胜利还是失败,她都不会在你背后留有空白;生命也不是一次彩排,走得不好还可以从头再来,她绝不给你第二次机会,走过去就无法回头。

    

第四步:打开*-Info.plistw文件,在配置文件中新增长一项  URL types(Array),在Array中增长一项 

    

   Item0            sinaweibosso.2279784657  

    

新浪微博授权。(如果不添加则会导致新浪微博的SSO授权方式无法返回应用)。

    


    


文章结束给大家分享下程序员的一些笑话语录: 古鸽是一种搜索隐禽,在中国快绝迹了…初步的研究表明,古鸽的离去,很可能导致另一种长着熊爪,酷似古鸽,却又习性不同的猛禽类——犤毒鸟

--------------------------------- 原创文章 By
添加和空间
---------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值