Closed Colir closed 10 years ago
Hi,
I guess the best way to handle this is to add a new case if the email already exists. Instead of returning false, just assume that if you have a 400 HTTP response code, it's because the email you POST already exists as a contact, so you get the contact who has this email with the following function :
function getContactByEmail($contactEmail) {
$mj = new Mailjet();
$params = array(
"method" => "VIEW",
"ID" => $contactEmail
);
$mj->contact($params);
}
(just a trick for this wrapper to make a request on https://api.mailjet.com/v3/REST/contact/youremail@test.com)
And then, you get the ID of the object returned by the previous function (the contact ID).
You now just have to add the contact with this ID to your list with the function addContactToList
written in the README file.
We just released a new PHP API wrapper. It is now more PHP-ish (including namespace, PSR-0 compliance, and globally a better architecture). All it requires is PHP 5.4
In addition to our API Guides, we would be happy to help you get started with it.
Guillaume, from Mailjet!
Hi, i try to add a contact to a list but without succes
here is my code
The problem is that on the first call, mailjet tell me that a contact with this email already exist.
So i can't assign him to a list I can't retrieve this contact ID
thanks for you help