I am trying to update the contact using the code:
$contact = new Contact(); $contact->id = $Customer['ContactId']; $contact->addEmail($allCustomers[$i]['email']); $contact->addList('1506197719'); $contact->first_name = $allCustomers[$i]['first_name']; $contact->last_name = $allCustomers[$i]['last_name']; $cc->contactService->updateContact($params['token'], $contact);
But got error: Ctct\Exceptions\CtctException: Forbidden
How I prepare the $contact object, for passing to updateContact function.
I can't use
$contactData = $cc->contactService->getContacts($params['token'], array("email" => 'firstname.lastname@example.org')); $contact = $contactData->results;
since it gives error (i don't know the reason).
So I decided to create the $contact object for update. I know the contact id and email of contact to update.
Your second code sample is the correct way to code the call. I'm wondering if there may be an underlying factor that is causing the error. Please try using our API Tester to get your contact by email address: https://constantcontact.mashery.com/io-docs
If you're getting an error response, please email us at email@example.com with the API Key, Access Token, and the email address you are working with when you get this error so that I can dig in further.
Tier II API Support Engineer