ChimpKit3
ChimpKit3 copied to clipboard
Update to support API 3.0 & Swift example
It would be greatly appreciated if we can update this library for the new API.
Also a swift example with completion block would be awesome too.
I'm also looking for a swift sample ;)
This is a functional sample :
ChimpKit.sharedKit().apiKey = "your api key"
let params:[NSObject : AnyObject] = ["id": "your list id", "email": ["email": "[email protected]"]]
ChimpKit.sharedKit().callApiMethod("lists/subscribe", withParams: params, andCompletionHandler: {(response, data, error) -> Void in
if let httpResponse = response as? NSHTTPURLResponse {
NSLog("Reponse status code: %d", httpResponse.statusCode)
}
})
@fabreax thanks for the help. I got it all setup and works perfectly.
Is there any way we can subscribe them so they don't have to confirm the email?
You should look at the "double_optin" parameter : https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
I think the API is still 2.0
I tried the double_optin parameter, I don't receive a confirmation email with :
let params:[NSObject : AnyObject] = ["id": listId, "email": ["email": email], "double_optin": false]
Not sure what is meant by this: "I think the API is still 2.0"
- MailChimp is still on 2.0 -> issue should remain closed
- ChimpKit is still on 2.0 -> issue needs to be reopened.
When checking the 2.0 docs, I get the following alert at the top of my view
I'm not the developer of this library. They say "ChimpKit is an API wrapper for the MailChimp API 2.0.".
Yea I saw that too. Ok so you are saying we should reopen this issue since its still valid. Cheers
Here is SWIFT 3 working example of subscribing user without email confirmation:
ChimpKit.shared().apiKey = "your_API_key"
let mailToSubscribe: [String: AnyObject] = ["email": "mail_you_want_to_subscribe" as AnyObject]
let params: [String: AnyObject] = ["id": "your_list_id" as AnyObject, "email": mailToSubscribe as AnyObject, "double_optin": false as AnyObject]
ChimpKit.shared().callApiMethod("lists/subscribe", withParams: params, andCompletionHandler: {(response, data, error) -> Void in
if let httpResponse = response as? HTTPURLResponse {
NSLog("Reponse status code: %d", httpResponse.statusCode)
let datastring = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
print(datastring) // printing result of response
}
})
Any update on moving to the 3.0 API? The documentation for 2.0 is no longer accessible via the website linked in the README: https://developer.mailchimp.com/
bump
Thanks @mozeb