Client.Create then Client.UpdateAccessAndBilling.php in one manouevre?

I've downloaded the PHP Wrapper for the API and all looks good, but I'm stuck on one step, after using Client.Create to creaate a new client, how do I capture the client_id to then continue with  Client.UpdateAccessAndBilling.php and other functions?

Thanks for any help

Joomailer Joomailer, 7 years ago

You could use  $clients =  $cm->userGetClients(  );  to get all clients returned in an array. Then you go through that array with foreach and use an if clause to find the client with the name you just created.

Cheers


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
Phil Phil, 7 years ago

Hi sgpratley,

In addition to what Joomailer says, a more direct method is to use the return value from the Client.Create procedure - a string containing the newly created ClientID.

Hope that helps :)

richardjkeys, 7 years ago

That would defienately be a preferred way to do it. I'm having some trouble getting this ID though!

I run this method:

$result=  $cm->clientCreate(  );

Obviously I fill the parameters. This successfully creates a new account within the system. However, the $result variable is an array, with size of 1, but $result[0] is blank. I assumed this should be the new client's ID?

Can anyone offer any advice for this?
____________________________________________________________________________________________

Edit:
The response came back nested in multiple arrays, once I'd sussed this I got it working fine!

jlorndorff, 6 years ago

I am having the same issue, can anyone help? Not sure how to get the clientID after the account is setup.

Here is my code so far:

$companyName = $_POST['companyName'];        
$contactName = $_POST['contactName'];
$emailAddress = $_POST['emailAddress'];
$country = $_POST['country'];
$timezone = $_POST['timezone'];

//-------------------------------------------------------------------------------    
    
    $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);
    



//-----------------------------INPUT PARAMS---------------------------------------

$apikey = '';
$client_id = '';
$accessLevel = '63';
$username = $_POST['apiusername'];
$password = $_POST['apiPassword'];
$billingType = 'ClientPaysWithMarkup';
$currency = 'USD';
$deliveryFee = '7';
$costPerRecipient = '3';
$designAndSpamTestFee = '10';
elixir, 6 years ago

The following will work.

$result = $cm->clientCreate(...);

$client_id = $result['anyType'];

In fact, the returned array need to be checked to make sure that there is no error. Otherwise, this will fail with 'invalid client id' message.

Use this when calling Client.UpdateAccessAndBilling.

Cheers,
Murali
Web Addons - www.elixiraddons.com

reldridge, 6 years ago

Did anyone get this working? Im not understanding how to go to the next step after the client is created... I just get the return value which i believe is the client id returned onto the screen?

Thanks again
Ryan.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098