网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

ios开发微博分享,ios发微博故事

ios sharesdk 新浪微博分享怎样拉起微博app

第一步:在targets-info-url types中添加一项,命名为wb+appid(到官网开放平台去申请)

成都网站制作、网站设计服务团队是一支充满着热情的团队,执着、敏锐、追求更好,是创新互联的标准与要求,同时竭诚为客户提供服务是我们的理念。成都创新互联公司把每个网站当做一个产品来开发,精雕细琢,追求一名工匠心中的细致,我们更用心!

第二步:写一个分享功能类

[objc] view plain copy print?

// 省略头文件

@interface HYBShareSDKHelper : NSObject

+ (void)registerShareSDK;

+ (BOOL)handleOpenURL:(NSURL *)url;

+ (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;

// 调用此方法来分享信息

typedef void (^HYBShareCompletion)(BOOL successful);

+ (void)shareWithContent:(NSString *)content

toController:(UIViewController *)controller

pngImage:(UIImage *)pngImage

title:(NSString *)title

url:(NSString *)url

mediaType:(SSPublishContentMediaType)mediaType

shareViewDelegate:(idISSShareViewDelegate)shareViewDelegate

completion:(HYBShareCompletion)completion;

@end

外部调用上面封装的方法来实现功能

[objc] view plain copy print?

//

// HYBShareSDKHelper.m

// CustomSharedSDKDemo

//

#import "HYBShareSDKHelper.h"

#import "HYBAppCommonInfoTool.h"

#import "HYBShareView.h"

#define kShareSDKAppKey @""

#define kShareSDKAppSecret @""

#define kSinaWeiboAppKey @""

#define kSinaWeiboAppSecret @""

@implementation HYBShareSDKHelper

+ (void)registerShareSDK {

[ShareSDK registerApp:kShareSDKAppKey];

// 添加新浪微博应用

NSString *redirectUri = @"";

// 添加新浪微博应用

[ShareSDK connectSinaWeiboWithAppKey:kSinaWeiboAppKey

appSecret:kSinaWeiboAppSecret

redirectUri:redirectUri];

// 当使用新浪微博客户端分享的时候需要按照下面的方法来初始化新浪的平台

[ShareSDK connectSinaWeiboWithAppKey:kSinaWeiboAppKey

appSecret:kSinaWeiboAppSecret

redirectUri:redirectUri

weiboSDKCls:[WeiboSDK class]];

return;

}

+ (BOOL)handleOpenURL:(NSURL *)url {

return [ShareSDK handleOpenURL:url wxDelegate:self];

}

+ (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:self];

}

// 这里是自己定制的弹出分享UI

+ (void)showShareViewInController:(UIViewController *)controller completion:(HYBShareClickBlock)completion {

HYBShareView *sv = [[HYBShareView alloc] initWithImages:@[@"sns_wx_icon", @"sns_wx_fr_icon", @"sns_qq_icon", @"sns_qzone_icon", @"sns_sina_icon"] titles:@[@"微信好友", @"微信朋友圈", @"QQ好友", @"QQ空间", @"新浪微博"] completion:^(NSUInteger index) {

if (completion) {

completion(index);

}

}];

[sv showInController:controller];

}

+ (void)shareWithContent:(NSString *)content

toController:(UIViewController *)controller

pngImage:(UIImage *)pngImage

title:(NSString *)title

url:(NSString *)url

mediaType:(SSPublishContentMediaType)mediaType

shareViewDelegate:(idISSShareViewDelegate)shareViewDelegate

completion:(HYBShareCompletion)completion {

// 分享内容

idISSContent sharedContent = [ShareSDK content:content

defaultContent:content

image:[ShareSDK pngImageWithImage:pngImage]

title: title

url:url

description:@"自己看着办"

mediaType:mediaType];

// 验证参数

idISSAuthOptions authOptions = [ShareSDK authOptionsWithAutoAuth:YES

allowCallback:YES

authViewStyle:SSAuthViewStyleFullScreenPopup

viewDelegate:nil

authManagerViewDelegate:nil];

// 显示分享列表

[self showShareViewInController:controller completion:^(NSUInteger index) {

if (index == 4) {// 新浪微博

[self shareToSinaWeiboWithContent:sharedContent authOptions:authOptions content:content pngImage:pngImage completion:^(BOOL successful) {

if (completion) {

completion(successful);

}

}];

}

}];

}

// 分享到Sina weibo

+ (void)shareToSinaWeiboWithContent:(idISSContent)sharedContent

authOptions:(idISSAuthOptions)authOptions

content:(NSString *)content

pngImage:(UIImage *)pngImage

completion:(HYBShareCompletion)completion {

[sharedContent addSinaWeiboUnitWithContent:content

image:[ShareSDK pngImageWithImage:pngImage]];

// if haven authorized, then call

if (![ShareSDK hasAuthorizedWithType:ShareTypeSinaWeibo]) {

[ShareSDK authWithType:ShareTypeSinaWeibo options:authOptions result:^(SSAuthState state, idICMErrorInfo error) {

if (state == SSAuthStateSuccess) {

idISSShareOptions shareOptions = [ShareSDK simpleShareOptionsWithTitle:@"美容总监"

shareViewDelegate:nil];

[ShareSDK clientShareContent:sharedContent

type:ShareTypeSinaWeibo

authOptions:authOptions

shareOptions:shareOptions

statusBarTips:YES

result:^(ShareType type, SSResponseState state, idISSPlatformShareInfo statusInfo, idICMErrorInfo error, BOOL end) {

if (completion end) {

DDLogVerbose(@"%@", error.errorDescription);

completion(state == SSPublishContentStateSuccess);

}

}];

}

}];

} else {// use client share to Sina App Client

idISSShareOptions shareOptions = [ShareSDK simpleShareOptionsWithTitle:@"美容总监"

shareViewDelegate:nil];

[ShareSDK clientShareContent:sharedContent

type:ShareTypeSinaWeibo

authOptions:authOptions

shareOptions:shareOptions

statusBarTips:YES

result:^(ShareType type, SSResponseState state, idISSPlatformShareInfo statusInfo, idICMErrorInfo error, BOOL end) {

if (completion end) {

DDLogVerbose(@"%@", error.errorDescription);

completion(state == SSPublishContentStateSuccess);

}

}];

}

}

@end

iOS 无新浪微博客户端时分享的问题

分享时,使用网页登陆后就出现 {"error":"userinfo error","pos":"5"} 这个错误信息

若是没有安装微博客户端,则使用网页登陆授权,进行分享。使用网页登陆后就出现{"error":"userinfo error","pos":"5"} 这个错误信息

在进行新浪微博分享的时候,最早在新浪微博开放中平台创建应用后,当是手机上没有安装新浪微博客户端时,进行分享时,如果没有添加测试账号的前提下在网页模式下分享内容到微博。就会出现这样的错误。

若是应用过审了,则任意微博账号都可以无阻的进行分享,但处于开发阶段,这个过审就是不可及的,所以就是添加测试账号。

添加测试账号方式:

在微博官方平台我的应用-应用右边:应用详情-左边:应用信息-高级信息-最下边:测试用户

使用iOS6,哪些内容可以分享到新浪微博?

您好,使用iOS6系统,您可以将iPhone中的照片、Safari网页、GameCenter数据分享到新浪微博。

ios开发分享到微博,怎么确定微博用户的授权状态?api里没有看到类似的接口

好吧,这个我也不知道,不过你可以去DevStore选一下,有源码下载

iOS 开发新浪微博分享功能在模拟器上运行的时候为什么提示要安装最新版新浪微博?

ios官方SDK是XCode,但其必须安装在苹果系统Mac OS下,你除非有苹果电脑或者安装了苹果虚拟机才能使用XCode,进而开发运行ios应用程序。

ios应用如果没上线能不能申请微博和QQ分享接口?

可以。

这些在你程序开发阶段就要申请,拿到授权后,在开发相应的功能,完了还要测试OK才会上架。

这个申请只需要提供相应的资质文件证明就可以了。


标题名称:ios开发微博分享,ios发微博故事
分享地址:http://bjjierui.cn/article/dsccgec.html

其他资讯