The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Account Provisioning API

Highlighted
Occasional Participant

Account Provisioning API

I'm trying to set up a page to allow our users to create a Constant Contact trial account (using the Account Provisioning API).  I have the page setup, but am getting an authentication error (401).    


How would I send the api username and password along with the xml string with the required header?  the docs I received are sparse on the login.  I know the login and password to use, but not sure where/how to use it.


Here are the instructions I was given.  


Creating a New Trial Account


In order to create a new trial account, you should use the POST method against the following URI, which refers to the partner side of our API package:


https://api.constantcontact.com/ws/partners/{partner-name}/siteowners


The parameter {partner-name} refers to the partner under which the account should be created.In order to use this API, you need to have a valid partner name and password.


For username, please use: {API-Key}%{partner-name}


All requests to the partners API must have the following header value added:accept: application/atom+xml



Is there a quick code sample around to show me?

Thanks, 

Jason

9 REPLIES 9
Highlighted
Employee

Re: Account Provisioning API

401 looks like an authentication error, are you using an actual business partner account name as opposed to your free Constant Contact account you receive when you become a business partner?


 


We do have a code samples of this in PHP and C#.NET. If you could let me know which one of these would be more helpful, I can get that sent over to you.

David J

Highlighted
Occasional Participant

RE: Account Provisioning API

 Yes, I'm using the actual business partner name and the login information for the bpconsole login (as I was told to)


I'm coding this up in PHP.  A sample would be great - I think I'm just not passing the data correctly.


Thanks!


Jason

Highlighted
Employee

RE: Account Provisioning API

I sent the sample over to the email address you registered this developer board account with. You can either respond here or to that email with any questions and I'll be happy to help.


 

David J

Highlighted
Occasional Participant

RE: Account Provisioning API

 David - 


The code sample worked well, that extra partner class is what I was looking for.  It almost works.  


I have it returning an error code 403 now.


 Here is my code:


include_once($site->IncludeDirectory().'Partner.php'); if((!empty($_POST) && ($_POST == $_POST))) { $cc_account = array( 'loginName' => $_POST, 'password' => $_POST, 'siteName' => $_POST, 'sitePhone' => $_POST, 'siteUrl' => '', 'siteSignature' => '', 'accountId' => $_SESSION->GetProperty('ID'), 'referralCode' => '', 'emailMarketing' => True // At least ONE of 'emailMarketing', 'survey', or 'eventMarketing' must be set to true ); $accountContact = array( 'firstName' => $_POST, 'lastName' => $_POST, 'phone' => $_POST, 'email' => $_POST, 'countryCode' => $_POST, 'stateCode' => $_POST, 'accountId' => $_SESSION->GetProperty('ID')); } $loginData = array( 'partnerName' => $CC_API_USER, 'password' => $CC_API_PASSWORD, 'apiKey' => $CC_API_KEY); // Setup the new account $Partner = new Partner($loginData); $CCAccount = new CCAccount($cc_account); $AccountContact = new AccountContact($accountContact); // Provision the new 'Account' with the provided 'Account Contact' under the provided 'Partner' account. $xml = $Partner->provisionAccount($CCAccount, $AccountContact); echo "


";          echo "

Output

"; print_r($xml); echo "

";


 

Highlighted
Employee

RE: Account Provisioning API

It sounds like your API Key does not have permission to provision new accounts, which is why its turning back a 403 - Forbidden error. If you want to either reply this post or my email with your username and API Key, I can certainly get the partner team to take a look at this for you.


 


I should also note I left a 'print_r($xmlReturn); on line 130 of the partner class (Partner class, _createPartnerXml function). You would probably want to remove this so you get a clear response back from the provisionAccount() function. Apologies.

David J

Highlighted
Occasional Participant

 Here's my api key and

 Here's my api key and user: 


 


    /*** constant contact ***/


    $CC_API_KEY = 'API_Key';


    $CC_API_USER = 'CC_Username';


 


I saw the print_r - thanks for letting me know.


 

Highlighted
Employee

Re: Here's my api key and

You should be all set now. If you run into any other issues please let me know. Thanks!

David J

Highlighted
New Member

Can you post a link to Partner.php?

Or the complete code sample?  Or email it to me?  Will that be open source or included in ctctWrapper.php anytime soon?


 


Thanks.

Highlighted
Employee

Re: Can you post a link to Partner.php?

I have emailed you the Partner.php as well as demo of how to use this piece of the library. We are planning on including this Partner in our next revision of our libraries, but I do not have an ETA of when those are going to be released. If you have any questions on this, please feel free to reply to my email or post here. Thanks

David J

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured