/** * function to get keyword report using user id * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * $info['from_time'] The from time of report in (yyyy-mm-dd) Eg: 2014-12-24 - Optional - (default => Yesterday) * $info['to_time'] The to time of report in (yyyy-mm-dd) Eg: 2014-12-28 - Optional - (default => Today) * @return Array $returnInfo Contains informations about keyword reports */ function getReportByUserId($info) { $userId = intval($info['id']); if (empty($userId)) { return array('response' => 'Error', 'result' => 'Invalid user id'); } $fromTime = getFromTime($info); $toTime = getToTime($info); // get all active websites $websiteController = new WebsiteController(); $websiteList = $websiteController->__getAllWebsitesWithActiveKeywords($userId, true); // loop through websites $keywordList = array(); foreach ($websiteList as $websiteInfo) { $websiteId = $websiteInfo['id']; $list = $this->ctrler->__getAllKeywords('', $websiteId); // loop through keywords foreach ($list as $keywordInfo) { $keywordList[$keywordInfo['id']] = $this->getFormattedReport($keywordInfo, $fromTime, $toTime); } } // if position information is not empty if (empty($keywordList)) { $returnInfo['response'] = 'Error'; $returnInfo['result'] = "No reports found!"; } else { $returnInfo['response'] = 'success'; $returnInfo['result'] = $keywordList; } return $returnInfo; }
/** * function to get website report using user id * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * $info['from_time'] The from time of report in (yyyy-mm-dd) Eg: 2014-12-24 - Optional - (default => Yesterday) * $info['to_time'] The to time of report in (yyyy-mm-dd) Eg: 2014-12-28 - Optional - (default => Today) * @return Array $returnInfo Contains informations about website reports */ function getReportByUserId($info) { // if not valid user $userId = intval($info['id']); if (empty($userId)) { return array('response' => 'Error', 'result' => 'Invalid user id'); } // get all active websites $wbList = $this->ctrler->__getAllWebsites($userId); $fromTime = getFromTime($info); $toTime = getToTime($info); // loop through websites $websiteList = array(); foreach ($wbList as $websiteInfo) { $websiteList[$websiteInfo['id']] = $this->getFormattedReport($websiteInfo, $fromTime, $toTime); } // if position information is not empty if (empty($websiteList)) { $returnInfo['response'] = 'Error'; $returnInfo['result'] = "No reports found!"; } else { $returnInfo['response'] = 'success'; $returnInfo['result'] = $websiteList; } return $returnInfo; }