Integrating API with a franchise site - C#


Integrating API with a franchise site - C#



I work for a franchise organization with over 100 locations, and I am trying to integrate a newsletter signup box into the individual homepages of each of our locations using the latest CTCT C# wrapper. Each franchise has their own unique CC account, which they manage. When a customer enters their address, the address should be entered into that location's contacts.


Will I need each franchisee to generate a unique API key and access token for their account? Then do something like this:


ConstantContact cc = new ConstantContact("[APIKEY]", "[TOKEN]");
CTCT.Components.Contacts.Contact contact = new CTCT.Components.Contacts.Contact();
contact.EmailAddresses.Add(new CTCT.Components.Contacts.EmailAddress(txtNewsletter.Text));
cc.AddContact(contact, true);


I appreciate any help or guidance.






The basic flow is completely correct, the only exception is that the API key is used to identify the developer, so you only need one of those.  You would need to generate an access_token for each of the franchise accounts.  There are two ways to do this:


1. Create a simple flow for the individual franchisees to grant access to you themselves

2. Generate all the OAuth tokens on behalf of the franchisees without them knowing (this requires you to know the Username/Passwords for all the accounts, which is common in our franchisor world since most of the franchisors create the accounts for the franchisees).


Depending on the information you have depends on which way you'd set this up.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page