<?php ini_set('display_errors', 1); error_reporting(E_ALL); require_once 'CMBase.php'; //-----------------------------INPUT PARAMS--------------------------------------- $apikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $companyName = 'Created From API'; $contactName = 'Joe Smith'; $emailAddress = '*****@*****.**'; $country = 'United States of America'; $timezone = '(GMT-05:00) Eastern Time (US & Canada)'; //------------------------------------------------------------------------------- $cm = new CampaignMonitor($apikey); //Optional statement to include debugging information in the result $cm->debug_level = 1; //This is the actual call to the method $result = $cm->clientCreate($companyName, $contactName, $emailAddress, $country, $timezone); echo '<br><br>'; print_r($result);
private function create_account($page_name) { if ($this->account_user->logged_in($this->site_id)) { # TODO: consider removing this duplication (of the dashboard) $wrapper = new View('public_account/accounts/dashboard'); $wrapper->page_name = $page_name; $wrapper->content = new View('public_account/accounts/dashboard_index'); $wrapper->content->account_user = $this->account_user->get_user(); $wrapper->content->page_name = $page_name; return $wrapper; } if ($_POST) { $post = new Validation($_POST); $post->pre_filter('trim'); $post->add_rules('email', 'required', 'valid::email'); $post->add_rules('username', 'required', 'valid::alpha_numeric'); $post->add_rules('password', 'required', 'matches[password2]', 'valid::alpha_dash'); if (!$post->validate()) { # $errors = arr::overwrite($_POST, $post->errors('form_error_messages')); return self::display_create($page_name, $_POST, $post->errors()); } # Create new user $account_user = ORM::factory('account_user'); if ($account_user->username_exists($_POST['username'], $this->site_id)) { return self::display_create($page_name, $_POST, 'username already exists'); } unset($_POST['password2']); $account_user->fk_site = $this->site_id; # load vars to user table foreach ($_POST as $key => $val) { $account_user->{$key} = $val; } # save the user if (!$account_user->save()) { return self::display_create($page_name, $_POST, 'There was a problem creating account.'); } # Log user in if (!$this->account_user->login($account_user, (int) $this->site_id, $_POST['password'])) { die('account created but login failed.'); } ## create new campaign monitor instance for plusjade accounts ## if (ROOTACCOUNT === $this->site_name) { $user = $this->account_user->get_user(); include Kohana::find_file('vendor', 'CMBase'); # Create new account. $company = $user->username; $name = $user->username; $email = $user->email; $country = 'United States of America'; $timezone = '(GMT-08:00) Pacific Time (US & Canada)'; $cm = new CampaignMonitor(); $result = $cm->clientCreate($company, $name, $email, $country, $timezone); if (is_string($result['anyType'])) { $user->cm_id = $result['anyType']; $user->save(); /* $accessLevel = '63'; $username = '******'; $password = '******'; $billingType = 'ClientPaysWithMarkup'; $currency = 'USD'; $deliveryFee = '7'; $costPerRecipient = '3'; $designAndSpamTestFee = '10'; $result = $cm->clientUpdateAccessAndBilling( $result['anyType'], $accessLevel, $user->username, $password, $billingType, $currency, $deliveryFee, $costPerRecipient, $designAndSpamTestFee ); */ } else { kohana::log('error', "{$result['anyType']['message']} : CM client {$user->username}"); #echo kohana::debug($result); } } # return the user dashboard. $wrapper = new View('public_account/accounts/dashboard'); $wrapper->page_name = $page_name; $wrapper->content = new View('public_account/accounts/dashboard_index'); $wrapper->content->account_user = $this->account_user->get_user(); $wrapper->content->page_name = $page_name; return $wrapper; # login success } return self::display_create($page_name); }