Welcome Guest, Not a member yet? Register   Sign In
Library: Campaign Monitor API
#1

[eluser]Ben Hirsch[/eluser]
Hi all. This is probably not the most elegant solution but it was a nice way to get CM working with CI quickly.

1) Grab the CM php sample from here: http://code.google.com/p/campaignmonitor...loads/list

2) Take the file CMBase.php from the download, rename it to CampaignMonitor.php and put it in your /system/application/libraries/ directory.

3) Find the following function (within the CampaignMonitor class):

Code:
function CampaignMonitor( $api = null, $client = null, $campaign = null, $list = null, $method = 'get' )
    {
        CMBase::CMBase( $api, $client, $campaign, $list, $method );
    }

and replace it with:

Code:
function CampaignMonitor( $api = null, $client = null, $campaign = null, $list = null, $method = 'get' )
    {
        $this->CI =& get_instance();
        CMBase::CMBase( $this->CI->cm_config['api'], $client, $campaign, $this->CI->cm_config['list'], $method );
    }

4) Then you can use it like this:

Code:
function _add_to_cm($email) {

        $this->cm_config = array(

                            'api'        => 'xxxxxxxxxxxx',
                            'list'        => 'xxxxxxxxxxxx'
                        );

        $this->load->library('CampaignMonitor');
        $result = $this->campaignmonitor->subscriberAdd($email, ''); // 2nd paramter could be used for name.
        
    }

... and you can use this function in your controller. Replace the api and list values with your own. (more info here: http://www.campaignmonitor.com/api/required/) Of course, you can use any CM API method you want. Just look at the documentation. But this will get you started with tunneling commands through the CM wrapper (CMBase.php) without having to make too many edits to the file.


Messages In This Thread
Library: Campaign Monitor API - by El Forum - 05-21-2009, 07:40 PM
Library: Campaign Monitor API - by El Forum - 07-16-2009, 07:49 AM
Library: Campaign Monitor API - by El Forum - 11-26-2009, 04:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB