十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
好吧,这个我也不知道,不过你可以去DevStore选一下,有源码下载
路桥网站制作公司哪家好,找创新互联建站!从网页设计、网站建设、微信开发、APP开发、自适应网站建设等网站项目制作,到程序开发,运营维护。创新互联建站成立与2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联建站。
第一步:在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
您好,使用iOS6系统,您可以将iPhone中的照片、Safari网页、GameCenter数据分享到新浪微博。
分享时,使用网页登陆后就出现 {"error":"userinfo error","pos":"5"} 这个错误信息
若是没有安装微博客户端,则使用网页登陆授权,进行分享。使用网页登陆后就出现{"error":"userinfo error","pos":"5"} 这个错误信息
在进行新浪微博分享的时候,最早在新浪微博开放中平台创建应用后,当是手机上没有安装新浪微博客户端时,进行分享时,如果没有添加测试账号的前提下在网页模式下分享内容到微博。就会出现这样的错误。
若是应用过审了,则任意微博账号都可以无阻的进行分享,但处于开发阶段,这个过审就是不可及的,所以就是添加测试账号。
添加测试账号方式:
在微博官方平台我的应用-应用右边:应用详情-左边:应用信息-高级信息-最下边:测试用户
可以用shareSDK
也可以用友盟分享
以上两种形式都能够实现分享功能