12
12
#import < LROAuth2Client/LROAuth2AccessToken.h>
13
13
14
14
15
- static NSString * const kFeedlyAPIBaseURLString = @" http://sandbox.feedly.com/v3" ;
16
- static NSString * const kFeedlyUserURLString = @" http://sandbox.feedly.com/v3/auth/auth" ;
17
- static NSString * const kFeedlyTokenURLString = @" http://sandbox.feedly.com/v3/auth/token" ;
15
+ static NSString * const kFeedlyAPIBaseURLString = @" http://cloud.feedly.com/v3" ;
16
+ static NSString * const kFeedlyUserURLString = @" http://cloud.feedly.com/v3/auth/auth" ;
17
+ static NSString * const kFeedlyTokenURLString = @" http://cloud.feedly.com/v3/auth/token" ;
18
+
19
+ static NSString * const kFeedlySandboxAPIBaseURLString = @" http://sandbox.feedly.com/v3" ;
20
+ static NSString * const kFeedlySandboxUserURLString = @" http://sandbox.feedly.com/v3/auth/auth" ;
21
+ static NSString * const kFeedlySandboxTokenURLString = @" http://sandbox.feedly.com/v3/auth/token" ;
22
+
23
+ static id _sharedInstance = nil ;
24
+ static dispatch_once_t onceToken;
18
25
19
26
@interface AFLClient ()
20
27
@property (strong ) AFeedlyAuthenticationBlock authenticationResultBlock;
@@ -26,9 +33,17 @@ @implementation AFLClient
26
33
27
34
#pragma mark - Initialization
28
35
36
+ + (instancetype )createSharedClient : (BOOL )inSandbox
37
+ {
38
+ dispatch_once (&onceToken, ^{
39
+ _sharedInstance = [[self alloc ] initWithBaseURL: [NSURL URLWithString: (inSandbox)?kFeedlySandboxAPIBaseURLString: kFeedlyAPIBaseURLString ]];
40
+ [(AFLClient*)_sharedInstance setIsInSandbox: inSandbox];
41
+ });
42
+
43
+ return _sharedInstance;
44
+ }
45
+
29
46
+ (instancetype ) sharedClient {
30
- static id _sharedInstance = nil ;
31
- static dispatch_once_t onceToken;
32
47
dispatch_once (&onceToken, ^{
33
48
_sharedInstance = [[self alloc ] initWithBaseURL: [NSURL URLWithString: kFeedlyAPIBaseURLString ]];
34
49
});
@@ -102,8 +117,8 @@ - (void)authenticateUsingWebview:(UIWebView*)webView
102
117
_oauthClient.delegate = self;
103
118
_oauthClient.debug = NO ;
104
119
105
- _oauthClient.userURL = [NSURL URLWithString: kFeedlyUserURLString ];
106
- _oauthClient.tokenURL = [NSURL URLWithString: kFeedlyTokenURLString ];
120
+ _oauthClient.userURL = [NSURL URLWithString: (_isInSandbox)? kFeedlySandboxUserURLString: kFeedlyUserURLString ];
121
+ _oauthClient.tokenURL = [NSURL URLWithString: (_isInSandbox)? kFeedlySandboxTokenURLString: kFeedlyTokenURLString ];
107
122
108
123
if ([self .token hasExpired ]) {
109
124
[_oauthClient refreshAccessToken: self .token];
0 commit comments