0

i have succesfully integrated the SendinBlue v3 API into my codeigniter application, but for some reason i'm unable to loop trough the results when using the API.

When i var_dump, my object looks like this :

 object(SendinBlue\Client\Model\GetEmailCampaigns)#110 (1) {
      ["container":protected]=>
      array(2) {
        ["campaigns"]=>
        array(2) {
          [0]=>
          array(23) {
            ["id"]=>
            int(2)
            ["name"]=>
            string(12) "Testcampagne"
            ["type"]=>
    .....

Since the root object is protected , i'm not able to loop trough this to see my campaigns. I was able to read it by converting it to an array , $result = (array)$result; and then i had to use

foreach ($result as $campaigns)
{
    foreach ($campaigns as $campaignh)
    {
         foreach ((array)$campaignh as $campaign)
         {
             echo $campaign['status'];
....    

I'm sure there must be a way to loop trough the campaigns in one single foreach? Feeling really stupid about this!

Thank you!

1 Answers1

2
$data = (array) $OBJECTfromSendInBlue;
$keys=array_keys(       $data);  
//print_r(  $keys   );
$contacts=$data[    $keys[0]];
print_r($contacts);

then you can easily loop $contacts. ;-)

Arnaldo Guido
  • 121
  • 1
  • 4