Welcome Guest, Not a member yet? Register   Sign In
[RESOLVED] How do I integrate the Campaign Monitor API Class?
#1

[eluser]Charles Garrison[/eluser]
I’m trying to create a library to integrate the Campaign Monitor API. Below is some sample code on how to add a subscriber - How do I make this work in CodeIgniter?

Code:
<?php
  require_once('CMBase.php');
    
  $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  $client_id = null;
  $campaign_id = null;
  $list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  $cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
    
  $result = $cm->subscriberAdd('[email protected]', 'Joe Smith');
    
  if($result['Result']['Code'] == 0)
    echo 'Success';
  else
    echo 'Error : ' . $result['Result']['Message'];
?>

Note: I posted this in another thread already by mistake.
#2

[eluser]Charles Garrison[/eluser]
Ok, I finally got this working - I was really over-thinking this!

For reference, here's how I did it:

Code:
function add_user() {
    $this->load->library( 'CMBase' );
        
    $api_key = 'xxxxxxxxxxxxxxxxxxxxxxx';
    $client_id = null;
    $campaign_id = null;
    $list_id = 'xxxxxxxxxxxxxxxxxxxxxxx';
        
    $cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );

    $result = $cm->subscriberAddWithCustomFields( '[email protected]', 'Joe Smith' );

    if($result['Result']['Code'] == 0)
        echo 'Success';
    else
        echo 'Error : ' . $result['Result']['Message'];
}
#3

[eluser]Mantishead[/eluser]
BTW - If you're running multiple clients under Campaign Monitor you will need to add the ClientID parameter as well. Hit settings the Client Settins button in CM to get the API Client ID.




Theme © iAndrew 2016 - Forum software by © MyBB