I try to add a contact to a list of contact in my Mailjet account, there is my code :
<?php
require('../mailjet_apiv3/src/Mailjet/php-mailjet-v3-simple.class.php');
$mj = new Mailjet($apiKey, $secretKey);
$list_id =123;
$params = array(
'method' => 'POST',
'Email' => 'test@tst.tst'
);
$result = $mj->contact($params);
if(isset($result->StatusCode) && $result->StatusCode == '400')
return false;
$contact_id = $result->Data[0]->ID;
// Add the contact to a contact list
$params = array(
'method' => 'POST',
'ContactID' => $contact_id,
'ListID' => $list_id
);
$result = $mj->listrecipient($params);
?>
I get this error : Notice: Trying to get property of non-object in .../addContactMailJet.php on line 30.
I could not find the problem, have someone idea what is wrong !