Get insights data for listener - ParllaySocial/parllay-php-sdk GitHub Wiki
Get insights data for listener
Code
require_once 'parllay.php';
$parllay = new Parllay(array(
"appId" => "YOUR_APP_ID",
"secret" => "YOUR_APP_SECRET"
));
$result = $parllay->api("/[YOUR_BUSINESS_ID]/insights", array(
"profile_id" => YOUR_PROFILE_ID,
"category" => "listener",
"keyword_groups" => array(
array(
"id" => KEYWORD_GROUP_ID,
"name" => "YOUR_KEYWORD_GROUP_NAME"
),
...
),
"metrics" => "city_distribution,emotion_distribution",
"since" => "2017-07-01",
"until" => "2017-07-01",
"kind" => "day"
));
Result
Array
(
[data] => Array
(
[0] => Array
(
[name] => city_distribution
[data] => Array
(
[0] => Array
(
[keyword_group] => Array
(
[id] => KEYWORDGROUP_ID
[name] => KEYWORDGROUP_NAME
)
[data] => Array
(
[0] => Array
(
[data_ids] => Array
(
[0] => 00000000235-Indonesia--Jakarta-2014-07
)
[city] => Jakarta
[message_count] => 721
)
[1] => Array
(
[data_ids] => Array
(
[0] => 00000000235-Indonesia--Bandung-2014-07
)
[city] => Bandung
[message_count] => 282
)
[2] => Array
(
[data_ids] => Array
(
[0] => 00000000235-UK--London-2014-07
)
[city] => London
[message_count] => 260
)
...
)
)
....
)
)
)
[1] => Array
(
[name] => emotion_distribution
[data] => Array
(
[0] => Array
(
[keyword_group] => Array
(
[id] => KEYWORDGROUP_ID
[name] => KEYWORDGROUP_NAME
)
[data] => Array
(
[0] => Array
(
[data_ids] => Array
(
[0] => 00000000235-twitter-0-2014-07
[1] => 00000000235-facebook-0-2014-07
)
[emotion] => Array
(
[id] => 0
[name] => Neutral
)
[message_count] => 226937
)
....
)
)
...
)
)
)
)
)
The Data Structure as follows:
{
"data" : [
{
"name" : "metric_name",
"data" : [
{
"keyword_group" : {
"id" : KEYWORD_GROUP_ID,
"name" : KEYWORD_GROUP_NAME
},
"data": [{},{}]
},
...
]
},
...
]
}