Foreach in variable that receives tickets from Zendesk api

1

I'm getting tickets for the Zendesk api, but I do not know how to give a foreach in the result by echoing the indexes.

$subdomain = "meusubdominio";
$username  = "[email protected]";
$token     = "xxx";
$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
$getTickets = $client->tickets()->findAll();

How do I give a foreach in $ getTickets, to echo the indexes? For example, I want to echo all indexes ["url"].

I know the example below is wrong, but it is to exemplify what I would like to do with the results.

I imagine you have to do some processing on $ getTickets before you get this result. I just do not know what to do.

Ex: 
foreach($getTickets as $Tct):
echo "<p>{$Tct['url']}</p>";
endforeach;

If I give a var_dump to it, I have the results as:

object(stdClass)#53 (4) { ["tickets"]=> array(11) { [0]=> object(stdClass)#45 (31) { ["url"]=> string(50) "https://......
    
asked by anonymous 26.08.2017 / 15:47

1 answer

0

Although I do not know the Zendesk API, because of the structure of the object you checked out in var_dump , this might work:

foreach ($getTickets->tickets as $ticket) {
   echo "<p>{$ticket->url}</p>";
};

Make sure this works. Otherwise, paste here the full output of a print_r ($ getTickets) , to better understand the structure of the object.

    
26.08.2017 / 16:21