Git Product home page Git Product logo

aspinboard's Introduction

ASPinboard

ASPinboard is the Objective-C library for Pinboard that powers Pushpin. It uses modern Objective-C features (such as ARC and blocks), supports iOS 5.1+, and is dead-simple to integrate. As of January 2013, ASPinboard has full support for every endpoint in the Pinboard API, except posts/recent.

Getting Started

The first thing you'll want to do is add the files in the ASPinboard directory to your application. Alternatively, you can drag and drop the Xcode project into your existing app, and create a workspace. It's really up to you.

Quickstart

ASPinboard uses the Pinboard's authentication token to access protected resources. You can retrieve a token with the authenticateWithUsername:password:success:failure method.

void (^loginFailureBlock)(NSError *);
loginFailureBlock = ^(NSError *error) {
   if (error.code == PinboardErrorInvalidCredentials) {
       // An invalid username or password was provided.
   }
   else if (error.code == PinboardErrorTimeout) {
       // The authentication request will time out if
       // it takes longer than 20 seconds to respond.
   }
};

ASPinboard *pinboard = [ASPinboard sharedInstance];
[pinboard authenticateWithUsername:PINBOARD_USERNAME
                          password:PINBOARD_PASSWORD
                           success:^(NSString *token) {
                               NSLog(@"Your Pinboard API token is: %@", token);
                           }
                           failure:loginFailureBlock];

After authenticating, ASPinboard stores the token internally for future requests.

If you want to use a token that you've previously stored or copied from your settings page, just use the setToken method on the ASPinboard shared instance before using ASPinboard to make requests to protected resources.

[pinboard setToken:token];

Retrieving Bookmarks

Now that you have a token, let's grab your bookmarks, shall we?

void (^successBlock)(NSArray *);
successBlock = ^(NSArray *bookmarks) {
    NSLog(@"Here are your bookmarks:");
    for (id bookmark in bookmarks) {
        NSLog(@"url: %@", bookmark[@"href"]);
    }
};

void (^failureBlock)(NSError *);
failureBlock = ^(NSError *error) {
   if (error != nil) {
       NSLog(@"Houston, we have a problem.");
   }
};

[pinboard bookmarksWithSuccess:successBlock failure:failureBlock];

Adding a Bookmark

[pinboard addBookmarkWithURL:@"https://pinboard.in/"
                       title:@"Pinboard"
                 description:@"A cool bookmarking site"
                        tags:@"bookmarking services"
                      shared:YES
                      unread:NO
                     success:^{}
                     failure:failureBlock];

This method can also be used to update an existing bookmark. For more information, see the Pinboard documentation for posts/add.

Other Methods

Please see ASPinboard.h for the full list of supported methods.

License

ASPinboard is available for use under the Apache License, Version 2.0. See LICENSE for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.