$stat = $_POST['stat']; $usersCount = $_POST['usersCount']; $dateRange = array('since' => strtotime($since), 'until' => strtotime($until)); try { // Create Facebook Instance $fb = new FbStats($config); $feedParams = array('sourceId' => $_POST['group'], 'limit' => 500, 'since' => urlencode($since), 'until' => urlencode($until)); //get Group Feed $groupFeed = $fb->getFeed($feedParams); } catch (Exception $e) { $response['error'] = $e->getMessage(); } if (!isset($response['error'])) { try { $users = $fb->getTopUsers($groupFeed, $stat, $usersCount); $response['success']['usersTable'] = getUsersTable($users, $stat); if ($users) { $response['success']['plainText'] = $messages[$stat] . ' since ' . $period[$since] . "\n --------------------------------------- \n"; $i = 1; foreach ($users as $user) { if ($user[$stat]) { $response['success']['plainText'] .= " \n" . $i++ . " " . $user['name'] . " with " . $user[$stat] . " " . $units[$stat]; //.= " \n". $i++ .". @[".$user['id'].":0:".$user['name']."] ".$user['name']." with ". $user[$stat]. " " . $units[$stat]; } } } } catch (Exception $e) { $response['error'] = $e->getMessage(); } } echo json_encode($response);
$action = $_POST["action"]; switch ($action) { case 'getStates': getStatesFromDb(); break; case 'getInstitutions': getInstitutionsFromDb(); break; case 'getRoles': getRolesFromDb(); break; case 'getInstitutionsTable': getInstitutionsTable(); break; case 'getUsersTable': getUsersTable(); break; case 'getChildrenTable': if ($_SESSION["rolId"] == 1) { getChildren(); } else { getChildrenByInstitution(); } break; case 'getChildrenTableByName': $name = $_POST["nombreChild"]; if ($_SESSION["rolId"] == 1) { getChildrenTableByName($name); } else { getChildrenTableByNameInInstitution($name); }