第一步:在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"} 這個錯誤信息
在進行新浪微博分享的時候,最早在新浪微博開放中平臺創建應用后,當是手機上沒有安裝新浪微博客戶端時,進行分享時,如果沒有添加測試賬號的前提下在網頁模式下分享內容到微博。就會出現這樣的錯誤。
若是應用過審了,則任意微博賬號都可以無阻的進行分享,但處于開發階段,這個過審就是不可及的,所以就是添加測試賬號。
添加測試賬號方式:
在微博官方平臺我的應用-應用右邊:應用詳情-左邊:應用信息-高級信息-最下邊:測試用戶
您好,使用iOS6系統,您可以將iPhone中的照片、Safari網頁、GameCenter數據分享到新浪微博。
好吧,這個我也不知道,不過你可以去DevStore選一下,有源碼下載
ios官方SDK是XCode,但其必須安裝在蘋果系統Mac OS下,你除非有蘋果電腦或者安裝了蘋果虛擬機才能使用XCode,進而開發運行ios應用程序。
可以。
這些在你程序開發階段就要申請,拿到授權后,在開發相應的功能,完了還要測試OK才會上架。
這個申請只需要提供相應的資質文件證明就可以了。
分享文章:ios開發微博分享,ios發微博故事
標題路徑:http://www.yijiale78.com/article42/dsccgec.html
成都網站建設公司_創新互聯,為您提供用戶體驗、微信公眾號、品牌網站設計、營銷型網站建設、App開發、定制網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯