The HW Blog

Want to be updated? @opencoconut | Feed

Introducing an Objective-C library

Bruno Celeste (@brunoceleste)

November 29, 2013 Features

We are pleased to announce the release of an Objective-C library to use Coconut directly in your iOS or Mac app.

To install it, you can use CocoaPods which is a dependency manager.

Start by editing your Podfile:

pod "Coconut"

Now run pod install to install the dependency.

#import "Coconut.h"

// Login with your Coconut API key
Coconut *hw = [[Coconut alloc] initWithApiKey:@"api_key"];

// Create a robot job by submitting the INI file
[hw createRobotJobFromFile(@"coconut.ini" complete:^(id jobObject, NSError *error) {
    if(error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"Job: %@", jobObject);
    }
}];

// Transfer a video
NSDictionary *params = @{@"url": @"http://site.com/yourvideo.mp4", @"title": @"filename"};
[hw create:@"download" parameters:params complete:^(id downloadObject, NSError *error) {
    if(error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"Download: %@", downloadObject);
    }
}];

// Create a new job
NSDictionary *params = @{
    @"video_id": @"9662090",
    @"format_id": @"mp4",
    @"ping_url": @"http://yoursite.com/ping/coconut?postid=123434",
    @"output_url": @"s3://accesskey:secretkey@myvideobucket/mp4/123434.mp4"
};

[hw create:@"job" parameters:params complete:^(id jobObject, NSError *error) {
    if(error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"Job: %@", jobObject);
    }
}];

You can improve the library by forking it on Github.



Any Comment? Send us a message on Twitter @opencoconut
If you have questions or feedbacks, you can also contact us via our contact page