Skip to content
This repository was archived by the owner on Jun 5, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressApi.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressApi"
s.version = "0.3.1"
s.version = "0.3.2"
s.summary = "A simple Objective-C client to publish posts on the WordPress platform"
s.homepage = "https://github.com/wordpress-mobile/WordPressApi"
s.license = { :type => 'MIT', :file => 'LICENSE.md' }
Expand Down
1 change: 1 addition & 0 deletions WordPressApi/WPComOAuthController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef NS_ENUM(NSUInteger, WPComOAuthErrorCode) {

- (void)setWordPressComUsername:(NSString *)username;
- (void)setWordPressComPassword:(NSString *)password;
- (void)setWordPressComAuthToken:(NSString *)authToken;

- (void)setClient:(NSString *)client;
- (void)setRedirectUrl:(NSString *)redirectUrl;
Expand Down
20 changes: 17 additions & 3 deletions WordPressApi/WPComOAuthController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ @interface WPComOAuthController () <UIWebViewDelegate,NSURLConnectionDelegate>
@end

@implementation WPComOAuthController {
NSString *_clientId, *_redirectUrl, *_scope, *_blogId, *_secret;
NSString *_username, *_password;
NSString *_clientId;
NSString *_redirectUrl;
NSString *_scope;
NSString *_blogId;
NSString *_secret;
NSString *_username;
NSString *_password;
NSString *_authToken;
BOOL _isSSO;
void (^_completionBlock)(NSString *token, NSString *blogId, NSString *blogUrl, NSString *scope, NSError *error);
}
Expand Down Expand Up @@ -61,6 +67,10 @@ - (void)setWordPressComPassword:(NSString *)password {
_password = password;
}

- (void)setWordPressComAuthToken:(NSString *)authToken {
_authToken = authToken;
}

- (void)setClient:(NSString *)client {
_clientId = client;
}
Expand All @@ -74,7 +84,7 @@ - (void)setSecret:(NSString *)secret {
}

- (void)setCompletionBlock:(void (^)(NSString *token, NSString *blogId, NSString *blogUrl, NSString *scope, NSError *error))completionBlock {
_completionBlock = completionBlock;
_completionBlock = [completionBlock copy];
}

#pragma mark - View lifecycle
Expand Down Expand Up @@ -128,6 +138,9 @@ - (void)viewDidAppear:(BOOL)animated {
[request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[request_body length]] forHTTPHeaderField:@"Content-Length"];
[request addValue:@"*/*" forHTTPHeaderField:@"Accept"];
if (_authToken) {
[request addValue:[NSString stringWithFormat:@"Bearer %@", _authToken] forHTTPHeaderField:@"Authorization"];
}
[request setHTTPMethod:@"POST"];
}
[self.webView loadRequest:request];
Expand Down Expand Up @@ -278,6 +291,7 @@ - (BOOL)handleOpenURL:(NSURL *)URL {
WPComOAuthController *ssoController = [[WPComOAuthController alloc] initForSSO];
[ssoController setWordPressComUsername:_username];
[ssoController setWordPressComPassword:_password];
[ssoController setWordPressComAuthToken:_authToken];
[ssoController setClient:clientId];
[ssoController setRedirectUrl:redirectUrl];
[ssoController present];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
E1F753CA14A094F400DB35A3 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = Automattic;
};
buildConfigurationList = E1F753CD14A094F400DB35A3 /* Build configuration list for PBXProject "WordPressApiExample" */;
Expand Down Expand Up @@ -345,9 +345,11 @@
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -379,9 +381,11 @@
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down