Showing posts with label mailchimp codeigniter. Show all posts
Showing posts with label mailchimp codeigniter. Show all posts

Sunday 30 November 2014

Mailchimp Integration CodeIgniter


Codeigniter MailChimp API v2 Wrapper

I am sharing my Codeigniter Code regarding Mailchimp integration. May this small code can be helpful for someone.

Reference - https://github.com/benbowler/codeigniter-mailchimp-api-v2



<?php 

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *         http://example.com/index.php/welcome
     *    - or - 
     *         http://example.com/index.php/welcome/index
     *    - or -
     * Since this controller is set as the default controller in
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */

    public function __construct() {
        parent::__construct();
        $this->load->library('Mailchimp_library');
    }

    public function index()
    {       
        $list_id = '';
        $lists = $this->mailchimp_library->call('lists/list');
        if(isset($lists["data"][0])) {
            $list_id = $lists["data"][0]["id"];
        }
        if(!empty($list_id)) {
            $result = $this->mailchimp_library->call('lists/subscribe', array(
                'id'                => $list_id,
                'email'             => array('email'=>'sourabhgupta3838@gmail.com'),
                'merge_vars'        => array('FNAME'=>'Sourabh', 'LNAME'=>'Gupta'),
                'double_optin'      => false,
                'update_existing'   => true,
                'replace_interests' => false,
                'send_welcome'      => false,
            ));
            print_r($result);
        }
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...