Skip to content
/ VisualSwift Public

Swift library for interfacing with the 23 Video API

License

Notifications You must be signed in to change notification settings

23/VisualSwift

Repository files navigation

VisualSwift

Version License Platform

Swift library for interfacing with the TwentyThree API.

Usage

After installation, import VisualSwift and init an API object with the domain and protocol of you TwentyThree account:

import VisualSwift

let visualAPI = VisualSwift(domain: "video.twentythree.net", scheme: "https")

If you need authorized access and have obtained the required API credentials, include these as a third argument when initializing the API object:

let credentials = [
    "consumer_key": "<consumer key>",
    "consumer_secret": "<consumer secret>",
    "access_token": "<access token>",
    "access_token_secret": "<access token secret>"
]
let visualAPI = VisualSwift(domain: "video.twentythree.net", scheme: "https", credentials: credentials)

Make requests

Now you're ready to start making requests against the API by calling the request() method of your API object. Read the API documentation on https://www.twentythree.net/api to get a list of available endpoints.

// Simple request
visualAPI.request("/api/photo/list") {
    result in
    if result.isSuccess {
        print(result.value)
    }
}

// Request with parameters
let parameters = [
    "album_id": "123456"
]
visualAPI.request("/api/photo/list", parameters: parameters) {...}

// Specify request method
let method = "GET"
visualAPI.request("/api/photo/list", parameters: parameters, method: method) {...}

// Specify cache usage
let useCache = true
visualAPI.request("/api/photo/list", parameters: parameters, method: method, useCache: useCache) {...}

Upload videos

let parameters = [
    "title": "My new video"
]
let fileURL: NSURL = <NSURL object>
visualAPI.uploadFile("/api/photo/upload", parameters: parameters, fileURL: fileURL, progressCallback: {
    progress in
    dispatch_async(dispatch_get_main_queue(), {
        print(progress)
    })
}) {
    result in
    if result.isSuccess {
        print(result.value)
    }
}

Installation

CocoaPods

VisualSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "VisualSwift"

Manual

Copy VisualSwift.swift and VisualSwiftUtils.swift from /Pod/Classes/ into your Xcode project.

Author

Kalle Kabell, kkabell@gmail.com

License

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