Skip to content

Commit

Permalink
Sina weibo now support OAuth 2 and more feature with sinaweibo-sso-oa…
Browse files Browse the repository at this point in the history
…uth sdk
  • Loading branch information
icyleaf committed Oct 25, 2012
1 parent a16b8a1 commit 5352dee
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 376 deletions.
22 changes: 14 additions & 8 deletions Classes/Example/ShareKitAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import "SHKReadItLater.h"
#import "SHKFacebook.h"
#import "SHKSinaWeibo.h"
#import "SHKConfiguration.h"
#import "ShareKitDemoConfigurator.h"

Expand All @@ -23,7 +24,8 @@ @implementation ShareKitAppDelegate
#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after app launch

//Here you load ShareKit submodule with app specific configuration
Expand Down Expand Up @@ -54,30 +56,34 @@ - (void)applicationWillTerminate:(UIApplication *)application

- (BOOL)handleOpenURL:(NSURL*)url
{
NSString* scheme = [url scheme];
if ([scheme hasPrefix:[NSString stringWithFormat:@"fb%@", SHKCONFIG(facebookAppId)]])
return [SHKFacebook handleOpenURL:url];
return YES;
NSString* scheme = [url scheme];
if ([scheme hasPrefix:[NSString stringWithFormat:@"fb%@", SHKCONFIG(facebookAppId)]])
return [SHKFacebook handleOpenURL:url];
else if ([scheme hasPrefix:[NSString stringWithFormat:@"sinaweibosso.%@", SHKCONFIG(sinaWeiboConsumerKey)]])
return [SHKSinaWeibo handleOpenURL:url];

return YES;
}

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [self handleOpenURL:url];
return [self handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application
handleOpenURL:(NSURL *)url
{
return [self handleOpenURL:url];
return [self handleOpenURL:url];
}

#pragma mark -
#pragma mark Memory management

- (void)dealloc {
- (void)dealloc
{
[navigationController release];
[window release];
[super dealloc];
Expand Down
19 changes: 16 additions & 3 deletions Classes/Example/ShareKitDemoConfigurator.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,23 @@ - (NSString*)appURL {
*/

// Sina Weibo
- (NSNumber *)forcePreSinaWeiboAccess


// If you want to force use of old-style, for example to ensure
// sina weibo accounts don't end up in the devices account store, set this to true.
- (NSNumber*)forcePreSinaWeiboAccess
{
return [NSNumber numberWithBool:false];
return [NSNumber numberWithBool:true];
}

// Fill sina weibo App Key(Consumer Key) below and Do not forget to fill it on facebook developer ("URL Scheme Suffix").
// Leave it blank unless you are sure of what you are doing.
//
// The CFBundleURLSchemes in your App-Info.plist should be "sinaweibosso." + App Key
// Example:
// sinaWeiboConsumerKey = 1631351849
//
// Your CFBundleURLSchemes entry: sinaweibosso.1631351849
- (NSString*)sinaWeiboConsumerKey {
return @"1631351849";
}
Expand All @@ -54,7 +66,8 @@ - (NSString*)sinaWeiboConsumerSecret {
return @"9164c304b4e547b8cdbf024fc4534720";
}

// You need to set this if using OAuth (MUST be set, it could be any words)
// You need to set this if using OAuth (MUST be set and SAME AS "Callback Url" of "OAuth 2.0 Auth Settings" on Sina Weibo open plaform.
// Url like this: http://open.weibo.com/apps/{app_key}/info/advanced
- (NSString*)sinaWeiboCallbackUrl {
return @"http://icyleaf.com";
}
Expand Down
17 changes: 12 additions & 5 deletions Classes/ShareKit/Configuration/DefaultSHKConfigurator.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@ - (NSString*)appURL {

// Sina Weibo - http://open.weibo.com/

/*
If you want to force use of old-style, for example to ensure
sina weibo accounts don't end up in the devices account store, set this to true.
*/
// If you want to force use of old-style, for example to ensure
// sina weibo accounts don't end up in the devices account store, set this to true.
- (NSNumber*)forcePreSinaWeiboAccess
{
return [NSNumber numberWithBool:false];
}

// Fill sina weibo App Key(Consumer Key) below and Do not forget to fill it on facebook developer ("URL Scheme Suffix").
// Leave it blank unless you are sure of what you are doing.
//
// The CFBundleURLSchemes in your App-Info.plist should be "sinaweibosso." + App Key
// Example:
// sinaWeiboConsumerKey = 1631351849
//
// Your CFBundleURLSchemes entry: sinaweibosso.1631351849
- (NSString*)sinaWeiboConsumerKey {
return @"";
}
Expand All @@ -78,7 +84,8 @@ - (NSString*)sinaWeiboConsumerSecret {
return @"";
}

// You need to set this if using OAuth (MUST be set, it could be any words)
// You need to set this if using OAuth (MUST be set and SAME AS "Callback Url" of "OAuth 2.0 Auth Settings" on Sina Weibo open plaform.
// Url like this: http://open.weibo.com/apps/{app_key}/info/advanced
- (NSString*)sinaWeiboCallbackUrl {
return @"";
}
Expand Down
34 changes: 4 additions & 30 deletions Classes/ShareKit/Sharers/Services/Sina Weibo/SHKSinaWeibo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,10 @@
#import <Foundation/Foundation.h>
#import "SHKOAuthSharer.h"
#import "SHKFormControllerLargeTextField.h"
#import "SinaWeibo.h"
#import "SinaWeiboRequest.h"

@interface SHKSinaWeibo : SHKOAuthSharer <SHKFormControllerLargeTextFieldDelegate>
{
BOOL xAuth;
}

@property BOOL xAuth;


#pragma mark -
#pragma mark UI Implementation

- (void)showSinaWeiboForm;

#pragma mark -
#pragma mark Share API Methods

- (void)sendStatus;
- (void)sendStatusTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data;
- (void)sendStatusTicket:(OAServiceTicket *)ticket didFailWithError:(NSError*)error;

- (void)sendImage;
- (void)sendImageTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data;
- (void)sendImageTicket:(OAServiceTicket *)ticket didFailWithError:(NSError*)error;

// TODO: Finish it below
//- (void)sendUserInfo;
//- (void)sendUserInfo:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data;
//- (void)sendUserInfo:(OAServiceTicket *)ticket didFailWithError:(NSError*)error;

- (void)followMe;
@interface SHKSinaWeibo : SHKOAuthSharer <SHKFormControllerLargeTextFieldDelegate, SinaWeiboDelegate, SinaWeiboRequestDelegate>

+ (BOOL)handleOpenURL:(NSURL*)url;
@end
Loading

0 comments on commit 5352dee

Please sign in to comment.