ChimpKit3 icon indicating copy to clipboard operation
ChimpKit3 copied to clipboard

Update to support API 3.0 & Swift example

Open acegreen opened this issue 9 years ago • 13 comments

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.

acegreen avatar Jan 10 '16 02:01 acegreen

I'm also looking for a swift sample ;)

fabreax avatar Jan 18 '16 09:01 fabreax

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 avatar Jan 20 '16 16:01 fabreax

@fabreax thanks for the help. I got it all setup and works perfectly.

acegreen avatar Jan 21 '16 00:01 acegreen

Is there any way we can subscribe them so they don't have to confirm the email?

acegreen avatar Jan 21 '16 05:01 acegreen

You should look at the "double_optin" parameter : https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php

fabreax avatar Jan 21 '16 09:01 fabreax

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]

fabreax avatar Jan 21 '16 09:01 fabreax

Not sure what is meant by this: "I think the API is still 2.0"

  1. MailChimp is still on 2.0 -> issue should remain closed
  2. 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 screen shot 2016-01-21 at 9 38 48 am

acegreen avatar Jan 21 '16 14:01 acegreen

I'm not the developer of this library. They say "ChimpKit is an API wrapper for the MailChimp API 2.0.".

fabreax avatar Jan 21 '16 14:01 fabreax

Yea I saw that too. Ok so you are saying we should reopen this issue since its still valid. Cheers

acegreen avatar Jan 21 '16 14:01 acegreen

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
                }
            })

mozeb avatar Nov 03 '16 11:11 mozeb

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/

jlaws avatar Jan 04 '17 06:01 jlaws

bump

anushkmittal avatar Dec 27 '17 16:12 anushkmittal

Thanks @mozeb

shubham14896 avatar May 11 '18 04:05 shubham14896