case 'follow':
     $isAjax = isset($_REQUEST['buckys_ajax']) ? true : false;
     if ($isAjax) {
         header('Content-type: application/xml');
     }
     if (!buckys_check_form_token('request')) {
         if ($isAjax) {
             $resultXML = ['status' => 'error', 'message' => MSG_INVALID_REQUEST];
             render_result_xml($resultXML);
             exit;
         } else {
             buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
         }
     }
     $paramPageID = get_secure_integer($_REQUEST['pid']);
     $result = $pageFollowerIns->addFollower($paramPageID, $userID);
     if ($result) {
         if ($isAjax) {
             $resultXML = ['status' => 'success', 'message' => 'MSG_FOLLOW_PAGE_SUCCESS', 'html' => 'Unfollow', 'link' => '/page.php?action=unfollow&pid=' . $paramPageID . buckys_get_token_param()];
             render_result_xml($resultXML);
             exit;
         } else {
             buckys_redirect('/page.php?pid=' . $paramPageID, MSG_FOLLOW_PAGE_SUCCESS, MSG_TYPE_SUCCESS);
         }
     } else {
         if ($isAjax) {
             $resultXML = ['status' => 'error', 'message' => MSG_FOLLOW_PAGE_FAIL];
             render_result_xml($resultXML);
             exit;
         } else {
             buckys_redirect('/page.php?pid=' . $paramPageID, MSG_FOLLOW_PAGE_FAIL, MSG_TYPE_ERROR);
 public function followAction()
 {
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     $pageID = isset($data['pageID']) ? $data['pageID'] : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     $pageFollowerIns = new BuckysPageFollower();
     $result = $pageFollowerIns->addFollower($pageID, $userID);
     if ($result) {
         $count = $pageFollowerIns->getNumberOfFollowers($pageID);
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "MESSAGE" => MSG_FOLLOW_PAGE_SUCCESS, "FOLLOWERS" => $count . " follower" . ($count > 1 ? "s" : "")]];
     } else {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_FOLLOW_PAGE_FAIL)];
     }
 }