Reputation: 47
I am making a request to mixpanel API
$data = $mp->request(array('segmentation'), array(
'event' => 'Loaded a Page',
'name' => 'Loaded a Page',
'from_date' => '2015-07-01',
'to_date' => '2015-07-01',
'type' => 'unique',
'expire' => '1439089200'
//'unit' => 'day',
//'interval' => '7',
//'format' => 'json'
));
//echo $data;
var_dump($data);
Here is the response I am getting.
object(stdClass)#2 (2) { ["legend_size"]=> int(1) ["data"]=> object(stdClass)#3 (2)
{ ["series"]=> array(1) { [0]=> string(10) "2015-07-01" } ["values"]=> object(stdClass)#4 (1)
{ ["Loaded a Page"]=> object(stdClass)#5 (1) { ["2015-07-01"]=> int(267691) } } } }
Can anyone please help me with how can I read the response in variables. Say I want to get the count of Loaded a Page event for '2015-07-01' from the response.
Upvotes: 0
Views: 384
Reputation: 72981
Say I want to get the count of Loaded a Page event for '2015-07-01' from the response.
$data->values->{"Loaded a Page"}->{"2015-07-01"}
Please note, this is a very nasty format. I would check if request()
takes parameters to adjust the format.
Nonetheless, I'd encourage you to read about Objects Properties in PHP and this answer Accessing Class Properties with Spaces.
Upvotes: 1