Sample code for 30+ languages & platforms
Swift

Magento Request with OAuth1.0a Authentication

See more Magento Examples

Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    http.oAuth1 = true
    http.oAuthVerifier = ""
    http.oAuthConsumerKey = "MAGENTO_CONSUMER_KEY"
    http.oAuthConsumerSecret = "MAGENTO_CONSUMER_SECRET"
    http.oAuthToken = "MAGENTO__TOKEN"
    http.oAuthTokenSecret = "MAGENTO_TOKEN_SECRET"

    http.accept = "application/json"

    var url: String? = "http://www.inart.com/api/rest/products/store/2?limit=20&page=1"

    var jsonStr: String? = http.quickGetStr(url: url)
    if http.lastMethodSuccess != true {
        print("\(http.lastErrorText!)")
        return
    }

    print("Response status code = \(http.lastStatus.intValue)")

    let json = CkoJsonObject()!
    json.load(json: jsonStr)
    json.emitCompact = false

    print("\(json.emit()!)")

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

}