I have a JSON string that I have just converted into a stdObject using this line of code:
$stdResponse = json_decode($jsonResponse);
This give me this object:
[02-Jul-2019 16:47:00 UTC] stdClass Object
(
[uuid] => qj/VA9z2SZKF6bT5FboOWf#$
[id] => 653070384
[topic] => Mark Test Meeting
)
Now I want to access the members of this object, for example the UUID. I tried just doing $stdResponse->uuid but that's an error.
THEN I tried converting the stdObject into the object that I really want using this PHP class:
class zoom_meeting
{
public $uuid;
public $id;
public $topic;
public function getUUID()
{
return ($this->uuid);
}
public function getMeetingId()
{
return ($this->id);
}
public function getMeetingName()
{
return ($this->topic);
}
}
I did that by using this line of code and a "cast" function I found elsewhere on this forum (that seems to work according to the comments):
$castMeeting = cast($stdResponse, "zoom_meeting");
Where the function cast is:
function cast($instance, $className)
{
return unserialize(sprintf(
'O:%d:"%s"%s',
strlen($className),
$className,
strstr(strstr(serialize($instance), '"'), ':')
));
}
It looked like it worked. Here is the object now:
[02-Jul-2019 16:47:00 UTC] CASTED MEETING:
[02-Jul-2019 16:47:00 UTC] zoom_meeting Object
(
[uuid] => qj/VA9z2SZKF6bT5FboOWf#$
[id] => 653070384
[topic] => Mark Test Meeting
)
Then I tried to use the get methods to "get" the information that I need out of this class object and here is the output of each call:
error_log(print_r($castMeeting->getUUID(), true));
[02-Jul-2019 16:47:00 UTC] 1
error_log(print_r($castMeeting->getMeetingId(), true));
[02-Jul-2019 16:47:00 UTC] 1
error_log(print_r($castMeeting->getMeetingName(), true));
[02-Jul-2019 16:47:00 UTC] 1
Just "1"'s and that's it. Clearly I am not getting the data I was expecting. Can anyone tell me what is going wrong here? Is there a better/cleaner way of just getting to the uuid, id, and topic values?
Any help or ideas would be MOST appreciated - Mark