可以。
成都创新互联主营椒江网站建设的网络公司,主营网站建设方案,成都APP应用开发,椒江h5成都微信小程序搭建,椒江网站营销推广欢迎椒江等地区企业咨询
这些在你程序开发阶段就要申请,拿到授权后,在开发相应的功能,完了还要测试OK才会上架。
这个申请只需要提供相应的资质文件证明就可以了。
ios官方SDK是XCode,但其必须安装在苹果系统Mac OS下,你除非有苹果电脑或者安装了苹果虚拟机才能使用XCode,进而开发运行ios应用程序。
第一步:在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
分享时,使用网页登陆后就出现 {"error":"userinfo error","pos":"5"} 这个错误信息
若是没有安装微博客户端,则使用网页登陆授权,进行分享。使用网页登陆后就出现{"error":"userinfo error","pos":"5"} 这个错误信息
在进行新浪微博分享的时候,最早在新浪微博开放中平台创建应用后,当是手机上没有安装新浪微博客户端时,进行分享时,如果没有添加测试账号的前提下在网页模式下分享内容到微博。就会出现这样的错误。
若是应用过审了,则任意微博账号都可以无阻的进行分享,但处于开发阶段,这个过审就是不可及的,所以就是添加测试账号。
添加测试账号方式:
在微博官方平台我的应用-应用右边:应用详情-左边:应用信息-高级信息-最下边:测试用户
好吧,这个我也不知道,不过你可以去DevStore选一下,有源码下载