Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit d0b4749

Browse files
authored
Added call to connect/site-info in BlogServiceRemote (#90)
* Added call to connect/site-info in BlogServiceRemote related issue: wordpress-mobile/WordPressAuthenticator-iOS#52 Purpose: Getting site info without authentication. * Added call to connect/site-info in BlogServiceRemote related issue: wordpress-mobile/WordPressAuthenticator-iOS#52 Purpose: Getting site info without authentication. * fix indentation * Updated according to code review
1 parent 7c883fd commit d0b4749

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

WordPressKit/BlogServiceRemoteREST.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,16 @@ typedef void (^SettingsHandler)(RemoteBlogSettings *settings);
5454
success:(void(^)(NSDictionary *siteInfoDict))success
5555
failure:(void (^)(NSError *error))failure;
5656

57+
/**
58+
* @brief Fetch site info (does not require authentication) for the specified site address.
59+
*
60+
* @note Uses anonymous API
61+
*
62+
* @param success The block that will be executed on success. Can be nil.
63+
* @param failure The block that will be executed on failure. Can be nil.
64+
*/
65+
- (void)fetchUnauthenticatedSiteInfoForAddress:(NSString *)siteAddress
66+
success:(void(^)(NSDictionary *siteInfoDict))success
67+
failure:(void (^)(NSError *error))failure;
68+
5769
@end

WordPressKit/BlogServiceRemoteREST.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,26 @@ - (void)fetchSiteInfoForAddress:(NSString *)siteAddress
287287
}];
288288
}
289289

290+
- (void)fetchUnauthenticatedSiteInfoForAddress:(NSString *)siteAddress
291+
success:(void(^)(NSDictionary *siteInfoDict))success
292+
failure:(void (^)(NSError *error))failure
293+
{
294+
NSString *path = [self pathForEndpoint:@"connect/site-info" withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
295+
NSURL *siteURL = [NSURL URLWithString:siteAddress];
296+
297+
[self.wordPressComRestApi GET:path
298+
parameters:@{ @"url": siteURL.absoluteString }
299+
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
300+
if (success) {
301+
success((NSDictionary *)responseObject);
302+
}
303+
} failure:^(NSError *error, NSHTTPURLResponse *httpResponse) {
304+
if(failure) {
305+
failure(error);
306+
}
307+
}];
308+
}
309+
290310
#pragma mark - API paths
291311

292312
- (NSString *)pathForUsers

0 commit comments

Comments
 (0)