SZNZotero 0.3.4

SZNZotero 0.3.4

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2015

Maintained by Vincent Tourraine.



 
Depends on:
AFOAuth1Client~> 1.0.0
TBXML~> 1.5
ISO8601DateFormatter~> 0.7
 

SZNZotero 0.3.4

Objective-C client for the Zotero API.

This is still in early stages of development, so proceed with caution when using this in a production application. Any bug reports, feature requests, or general feedback at this point would be greatly appreciated.

SZNZotero is a Zotero API client for iOS and Mac OS X, built on top of AFNetworking.

Getting Started

Installation

CocoaPods is the recommended way to add SZNZotero to your project. CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SZNZotero in your projects.

Here’s an example podfile that installs SZNZotero and all its dependencies.

platform :ios, '5.0'

pod 'SZNZotero', '~> 0.3.4'

OAuth callback URL

The Zotero API v2 uses 3leg OAuth 1.0 authentication. In order to gain access to protected resources, your application will open Mobile Safari and prompt for user credentials. iOS will then switch back to your application using a custom URL scheme. It means that you need to set it up in your Xcode project.

  • Open the project editor, select your main target, click the Info button.
  • Add a URL Type, and type a unique URL scheme (for instance ’myzoteroclient’).
  • Update your app delegate to notify SZNZotero as following:
#import "AFOAuth1Client.h"

NSString * const SZNURLScheme = @"##my_URL_scheme##";

(…)

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if ([url.scheme isEqualToString:SZNURLScheme]) {
        NSNotification *notification = [NSNotification notificationWithName:kAFApplicationLaunchedWithURLNotification object:nil userInfo:@{kAFApplicationLaunchOptionsURLKey: url}];
        [[NSNotificationCenter defaultCenter] postNotification:notification];
    }

    return YES;
}

App credentials

You need to instanciate the Zotero API client with your API consumer key and secret:

NSString *clientKey    = @"###my_consumer_key###";
NSString *clientSecret = @"###my_consumer_secret###";

SZNZoteroAPIClient *client = [[SZNZoteroAPIClient alloc] initWithKey:clientKey secret:clientSecret URLScheme:SZNURLScheme];

If you don’t have a consumer key and secret, you must register your application with Zotero.

Examples

How to fetch the top items in a collection

SZNCollection *parentCollection = ...;

[parentCollection fetchTopItemsSuccess:^(NSArray *items) {
     /* ... */
} failure:^(NSError *error) {
    /* ... */
}];

How to create a new item

SZNLibrary *library = ...;
NSDictionary *itemFields = ...;

[SZNItem createItemInLibrary:library content:itemFields success:^(SZNItem *newItem) {
     /* ... */
} failure:^(NSError *error) {
    /* ... */
}];

References

Requirements

SZNZotero requires Xcode 4.4 with either the iOS 5.0 or Mac OS X 10.7, as well as AFNetworking, AFOAuth1Client, TBXML, and ISO8601DateFormatter. SZNZotero uses ARC.

Credits

SZNZotero is developed by shazino.

License

SZNZotero is available under the MIT license. See the LICENSE file for more info.