No title

verifyAPICredentials($inputInfo)) { $category = strtolower($inputInfo['category']); $action = $inputInfo['action']; // check for category and action values if (!empty($category) && !empty($action)) { // call api class with the action if (include(SP_ABSPATH . "/api/" . $category . ".api.php")) { $categortClassName = ucfirst($category) . "API"; // check for class exists or not if (class_exists($categortClassName)) { $apiObj = new $categortClassName(); // check action exists or not if (method_exists($apiObj, $action)) { $returnInfo = $apiObj->$action($inputInfo); } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Action is not supported!"; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Category is not supported!"; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Invalid category passed!"; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Invalid category or action!"; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "API Authentication failed. Please provide valid API key and secret!"; } // for debugging added below line // debugVar($returnInfo);exit; // encode as json and print $out = json_encode($returnInfo); print $out; ?> ctrler = new KeywordController(); $this->reportCtrler = New ReportController(); $seController = New SearchEngineController(); $list = $seController->__getAllSearchEngines(); $this->seList = array(); // loop through the search engine and assign id as key foreach ($list as $listInfo) { $this->seList[$listInfo['id']] = $listInfo; } } /** * function to get keyword report and format it * @param array $keywordInfo The information about keyword * @param int $fromTime The time stamp of from time * @param int $toTime The time stamp of to time * @return $keywordInfo The formatted keyword info with position details */ function getFormattedReport($keywordInfo, $fromTime, $toTime) { $positionInfo = $this->reportCtrler->__getKeywordSearchReport($keywordInfo['id'], $fromTime, $toTime, true); // loop through and add search engine name foreach ($positionInfo as $seId => $info) { $positionInfo[$seId]['search_engine'] = $this->seList[$seId]['domain']; $positionInfo[$seId]['date'] = date('Y-m-d', $toTime); } $keywordInfo['position_info'] = $positionInfo; return $keywordInfo; } /** * function to get keyword report using keyword id * @param Array $info The input details to process the api * $info['id'] The id of the keyword - 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 getReportById($info) { $fromTime = getFromTime($info); $toTime = getToTime($info); $keywordInfo = $this->ctrler->__getKeywordInfo($info['id']); $positionInfo = $this->getFormattedReport($keywordInfo, $fromTime, $toTime); // if position information is not empty if (empty($positionInfo)) { $returnInfo['response'] = 'Error';; $returnInfo['result'] = "No reports found!"; } else { $returnInfo['response'] = 'success'; $returnInfo['result'] = $positionInfo; } return $returnInfo; } /** * function to get keyword report using website id * @param Array $info The input details to process the api * $info['id'] The id of the website - 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 getReportByWebsiteId($info) { $websiteId = intval($info['id']); if (empty($websiteId)) { return array( 'response' => 'Error', 'result' => 'Invalid website id' ); } $fromTime = getFromTime($info); $toTime = getToTime($info); $list = $this->ctrler->__getAllKeywords('', $websiteId); // lopp through keywords $keywordList = array(); 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 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 keyword information * @param Array $info The input details to process the api * $info['id'] The id of the keyword - Mandatory * @return Array $returnInfo Contains informations about keyword */ function getKeywordInfo($info) { $keywordId = intval($info['id']); $returnInfo = array(); // validate the keyword id and keyword info if (!empty($keywordId)) { if ($keywordInfo = $this->ctrler->__getKeywordInfo($keywordId)) { $returnInfo['response'] = 'success'; $returnInfo['result'] = $keywordInfo; return $returnInfo; } } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid keyword id provided"; return $returnInfo; } /** * function to get website keywords * @param Array $info The input details to process the api * $info['id'] The id of the website - Mandatory * $info['status'] The status of the keyword * $info['search'] The search keyword * @return Array $returnInfo Contains informations about keyword */ function getWebsiteKeywords($info) { $websiteId = intval($info['id']); $returnInfo = array(); // validate the website id if (!empty($websiteId)) { $keywordList = $this->ctrler->__getWebisteKeywords($websiteId, $info); $returnInfo['response'] = 'success'; $returnInfo['result'] = $keywordList; return $returnInfo; } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid website id provided"; return $returnInfo; } /** * function to create keyword * @param Array $info The input details to process the api * $info['name'] The name of the keyword - Mandatory * $info['website_id'] The website id of keyword - Mandatory * $info['searchengines'] The search engine ids of the keyword - Mandatory[id1:id2] * $info['lang_code'] The language code of the keyword - Optional[de] * $info['country_code'] The country code of the keyword - Optional[ar] * $info['status'] The status of the keyword - default[1] - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function createKeyword($info) { // if empty website id provided if (empty($info['website_id'])) { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Please provide valid website id."; return $returnInfo; } $keywordInfo = $info; $keywordInfo['userid'] = $info['user_id']; $this->ctrler->spTextKeyword = $this->ctrler->getLanguageTexts('keyword', SP_API_LANG_CODE); $keywordInfo['searchengines'] = explode(':', $keywordInfo['searchengines']); $return = $this->ctrler->createKeyword($keywordInfo, true); // if keyword creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; $returnInfo['keyword_id'] = $this->ctrler->db->getMaxId('keywords'); } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } return $returnInfo; } /** * function to update keyword * @param Array $info The input details to process the api * $info['id'] The id of the keyword - Mandatory * $info['name'] The name of the keyword - Optional * $info['lang_code'] The language code of the keyword - Optional[de,fr] * $info['country_code'] The country code of the keyword - Optional[ar,in] * $info['website_id'] The description of keyword - Optional * $info['searchengines'] The search engine ids of the keyword - Optional[id1:id2] * $info['status'] The status of the keyword - default[1] - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function updateKeyword($info) { $keywordId = intval($info['id']); // if keyword exists if ($keywordInfo = $this->ctrler->__getKeywordInfo($keywordId)) { $keywordInfo['oldName'] = $keywordInfo['name']; // loop through inputs foreach ($info as $key => $val) { $keywordInfo[$key] = $val; } // update keyword call as api call $keywordInfo['searchengines'] = explode(':', $keywordInfo['searchengines']); $this->ctrler->spTextKeyword = $this->ctrler->getLanguageTexts('keyword', SP_API_LANG_CODE); $return = $this->ctrler->updateKeyword($keywordInfo, true); // if keyword creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid keyword id provided"; } return $returnInfo; } /** * function to delete keyword * @param Array $info The input details to process the api * $info['id'] The id of the keyword - Mandatory * @return Array $returnInfo Contains details about the operation succes or not */ function deleteKeyword($info) { $keywordId = intval($info['id']); // if keyword exists if ($keywordInfo = $this->ctrler->__getKeywordInfo($keywordId)) { // update keyword call as api call $this->ctrler->__deleteKeyword($keywordId); $returnInfo['response'] = 'success'; $returnInfo['result'] = "Successfully deleted keyword"; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid keyword id provided"; } return $returnInfo; } } ?> ctrler = new SearchEngineController(); } /** * function to get all search engines * @param Array $info The input details to process the api * $info['status'] The status of the search engine * $info['search'] The search keyword * @return Array $returnInfo Contains informations about keyword */ function getSearchengines($info) { $returnInfo = array(); $resultList = $this->ctrler->__searchSerachEngines($info); $returnInfo['response'] = 'success'; $returnInfo['result'] = $resultList; return $returnInfo; } } ?> ctrler = new UserController(); } /** * function to get user information * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * @return Array $returnInfo Contains informations about user */ function getUserInfo($info) { $userId = intval($info['id']); $returnInfo = array(); // validate the user ifd and user info if (!empty($userId)) { if ($userInfo = $this->ctrler->__getUserInfo($userId)) { $userInfo['password'] = ''; $returnInfo['response'] = 'success'; $returnInfo['result'] = $userInfo; return $returnInfo; } } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid user id provided"; return $returnInfo; } /** * function to create user * @param Array $info The input details to process the api * $info['username'] The username of the user - Mandatory * $info['password'] The password of the user - Mandatory * $info['first_name'] The first name f the user - Mandatory * $info['last_name'] The last name of user - Optional * $info['email'] The user email - Mandatory * $info['type_id'] The user type id of user - default[2] - Optional * $info['status'] The status of the user - default[1] - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function createUser($info) { $userInfo = $info; $userInfo['userName'] = $info['username']; $userInfo['firstName'] = $info['first_name']; $userInfo['lastName'] = $info['last_name']; $userInfo['confirmPassword'] = $userInfo['password']; $return = $this->ctrler->createUser($userInfo, false); // if user creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; $returnInfo['user_id'] = $this->ctrler->db->getMaxId('users'); } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } return $returnInfo; } /** * function to update user * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * $info['username'] The username of the user - Optional * $info['password'] The password of the user - Optional * $info['first_name'] The first name f the user - Optional * $info['last_name'] The last name of user - Optional * $info['email'] The user email - Optional * $info['type_id'] The user type id of user - Optional * $info['status'] The status of the user - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function updateUser($info) { $userId = intval($info['id']); // if user exists if ($userInfo = $this->ctrler->__getUserInfo($userId)) { $userInfo['oldName'] = $userInfo['username']; $userInfo['oldEmail'] = $userInfo['email']; // loop through inputs foreach ($info as $key => $val) { $userInfo[$key] = $val; } // updte user info $userInfo['userName'] = $userInfo['username']; $userInfo['firstName'] = $userInfo['first_name']; $userInfo['lastName'] = $userInfo['last_name']; $userInfo['confirmPassword'] = $userInfo['password']; $return = $this->ctrler->updateUser($userInfo, false); // if user creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid user id provided"; } return $returnInfo; } /** * function to delete user * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * @return Array $returnInfo Contains details about the operation success or not */ function deleteUser($info) { $userId = intval($info['id']); // if user exists if ( ($userId != 1) && $userInfo = $this->ctrler->__getUserInfo($userId)) { // update user call as api call $this->ctrler->__deleteUser($userId); $returnInfo['response'] = 'success'; $returnInfo['result'] = "Successfully deleted user"; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid user id provided"; } return $returnInfo; } /** * function added by Rex, 2020Media.com * function to get user id from username * @param Array $info The input details to process the api * $info['username'] The username of the user - Mandatory * @return Array $returnInfo Contains id of user */ function getUserName($info) { $username = $info['username']; $returnInfo = array(); // validate the user ifd and user info if (!empty($username)) { if ($userInfo = $this->ctrler->__checkUserName($username)) { $returnInfo['response'] = 'success'; $returnInfo['result'] = $userInfo; return $returnInfo; } } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "Invalid username provided"; return $returnInfo; } } ?> ctrler = new WebsiteController(); $seController = New SearchEngineController(); $list = $seController->__getAllSearchEngines(); $this->seList = array(); // loop through the search engine and assign id as key foreach ($list as $listInfo) { $this->seList[$listInfo['id']] = $listInfo; } include_once(SP_CTRLPATH."/saturationchecker.ctrl.php"); include_once(SP_CTRLPATH."/rank.ctrl.php"); include_once(SP_CTRLPATH."/backlink.ctrl.php"); include_once(SP_CTRLPATH."/directory.ctrl.php"); include_once(SP_CTRLPATH."/keyword.ctrl.php"); include_once(SP_CTRLPATH."/pagespeed.ctrl.php"); } /** * function to get website reports rank, backlinks, saturation and directory submission * @param array $websiteInfo The information about website * @param int $fromTime The time stamp of from time * @param int $toTime The time stamp of to time * @return $websiteInfo The formatted website info with position details */ function getFormattedReport($websiteInfo, $fromTime, $toTime) { // create required controllers $rankCtrler = New RankController(); $backlinlCtrler = New BacklinkController(); $saturationCtrler = New SaturationCheckerController(); $dirCtrler = New DirectoryController(); $pagespeedCtrler = New PageSpeedController(); // rank reports $report = $rankCtrler->__getWebsiteRankReport($websiteInfo['id'], $fromTime, $toTime); $report = $report[0]; $toTimeDate = date('Y-m-d', $toTime); $websiteInfo['alexa']['alexarank']['rank'] = empty($report['alexa_rank']) ? "-" : $report['alexa_rank']; $websiteInfo['alexa']['alexarank']['diff'] = removeBraces($report['rank_diff_alexa']); $websiteInfo['alexa']['alexarank']['date'] = $toTimeDate; $websiteInfo['moz']['pagerank']['rank'] = empty($report['moz_rank']) ? "-" : $report['moz_rank']; $websiteInfo['moz']['pagerank']['diff'] = removeBraces($report['rank_diff_moz']); $websiteInfo['noz']['pagerank']['date'] = $toTimeDate; // back links reports $report = $backlinlCtrler->__getWebsitebacklinkReport($websiteInfo['id'], $fromTime, $toTime); $report = $report[0]; $websiteInfo['google']['backlinks']['rank'] = empty($report['google']) ? "-" : $report['google']; $websiteInfo['google']['backlinks']['diff'] = $report['rank_diff_google']; $websiteInfo['google']['backlinks']['date'] = $toTimeDate; $websiteInfo['alexa']['backlinks']['rank'] = empty($report['alexa']) ? "-" : $report['alexa']; $websiteInfo['alexa']['backlinks']['diff'] = $report['rank_diff_alexa']; $websiteInfo['alexa']['backlinks']['date'] = $toTimeDate; $websiteInfo['bing']['backlinks']['rank'] = empty($report['msn']) ? "-" : $report['msn']; $websiteInfo['bing']['backlinks']['diff'] = $report['rank_diff_msn']; $websiteInfo['bing']['backlinks']['date'] = $toTimeDate; // saturaton rank reports $report = $saturationCtrler->__getWebsiteSaturationReport($websiteInfo['id'], $fromTime, $toTime); $report = $report[0]; $websiteInfo['google']['indexed']['rank'] = empty($report['google']) ? "-" : $report['google']; $websiteInfo['google']['indexed']['diff'] = $report['rank_diff_google']; $websiteInfo['google']['indexed']['date'] = $toTimeDate; $websiteInfo['bing']['indexed']['rank'] = empty($report['msn']) ? "-" : $report['msn']; $websiteInfo['bing']['indexed']['diff'] = $report['rank_diff_msn']; $websiteInfo['bing']['indexed']['date'] = $toTimeDate; // directory submission stats $websiteInfo['dirsub']['total'] = $dirCtrler->__getTotalSubmitInfo($websiteInfo['id']); $websiteInfo['dirsub']['active'] = $dirCtrler->__getTotalSubmitInfo($websiteInfo['id'], true); $websiteInfo['dirsub']['date'] = $toTimeDate; // pagespeed reports $report = $pagespeedCtrler->__getWebsitePageSpeedReport($websiteInfo['id'], $fromTime, $toTime); $report = $report[0]; $websiteInfo['google']['pagespeed']['desktop_speed'] = empty($report['desktop_speed_score']) ? "-" : $report['desktop_speed_score']; $websiteInfo['google']['pagespeed']['ds_diff'] = empty($report['rank_diff_desktop_speed_score']) ? "-" : $report['rank_diff_desktop_speed_score']; $websiteInfo['google']['pagespeed']['mobile_speed'] = empty($report['mobile_speed_score']) ? "-" : $report['mobile_speed_score']; $websiteInfo['google']['pagespeed']['ms_diff'] = empty($report['rank_diff_mobile_speed_score']) ? "-" : $report['rank_diff_mobile_speed_score']; $websiteInfo['google']['pagespeed']['mobile_usability'] = empty($report['mobile_usability_score']) ? "-" : $report['mobile_usability_score']; $websiteInfo['google']['pagespeed']['mu_diff'] = empty($report['rank_diff_mobile_usability_score']) ? "-" : $report['rank_diff_mobile_usability_score']; $websiteInfo['google']['pagespeed']['date'] = $toTimeDate; return $websiteInfo; } /** * function to get website report using website id * @param Array $info The input details to process the api * $info['id'] The id of the website - 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 getReportById($info) { $fromTime = getFromTime($info); $toTime = getToTime($info); $websiteInfo = $this->ctrler->__getWebsiteInfo($info['id']); // if website not exists if (empty($websiteInfo['id'])) { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid website id provided"; } else { $returnInfo['response'] = 'success'; $returnInfo['result'] = $this->getFormattedReport($websiteInfo, $fromTime, $toTime); } 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; } /** * function to get website information * @param Array $info The input details to process the api * $info['id'] The id of the website - Mandatory * @return Array $returnInfo Contains informations about website */ function getWebsiteInfo($info) { $websiteId = intval($info['id']); $returnInfo = array(); // validate the website ifd and website info if (!empty($websiteId)) { if ($websiteInfo = $this->ctrler->__getWebsiteInfo($websiteId)) { $returnInfo['response'] = 'success'; $returnInfo['result'] = $websiteInfo; return $returnInfo; } } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid website id provided"; return $returnInfo; } /** * function to get user websites * @param Array $info The input details to process the api * $info['id'] The id of the user - Mandatory * $info['status'] The status of the websites[0/1] * $info['search'] The search keyword * @return Array $returnInfo Contains informations about website */ function getUserWebsites($info) { $userId = intval($info['id']); $returnInfo = array(); // validate the website ifd and website info if (!empty($userId)) { $websiteList = $this->ctrler->__getUserWebsites($userId, $info); $returnInfo['response'] = 'success'; $returnInfo['result'] = $websiteList; return $returnInfo; } $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid user id provided"; return $returnInfo; } /** * function to create website * @param Array $info The input details to process the api * $info['name'] The name of the website - Mandatory * $info['url'] The url of the website - Mandatory * $info['user_id'] The user id of website - Mandatory * $info['title'] The title of the website - Optional * $info['description'] The description of website - Optional * $info['keywords'] The keyword of the website - Optional * $info['status'] The status of the website - default[1] - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function createWebsite($info) { $websiteInfo = $info; // check for user id if (empty($info['user_id'])) { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = 'Invalid user id'; return $returnInfo; } $websiteInfo['userid'] = $info['user_id']; $this->ctrler->spTextWeb = $this->ctrler->getLanguageTexts('website', SP_API_LANG_CODE); $return = $this->ctrler->createWebsite($websiteInfo, true); // if website creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; $returnInfo['website_id'] = $this->ctrler->db->getMaxId('websites'); } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } return $returnInfo; } /** * function to update website * @param Array $info The input details to process the api * $info['id'] The id of the website - Mandatory * $info['name'] The name of the website - Optional * $info['url'] The url of the website - Optional * $info['title'] The title of the website - Optional * $info['description'] The description of website - Optional * $info['keywords'] The keyword of the website - Optional * $info['user_id'] The user id of website - Optional * $info['status'] The status of the website - default[1] - Optional * @return Array $returnInfo Contains details about the operation succes or not */ function updateWebsite($info) { $websiteId = intval($info['id']); // if website exists if ($websiteInfo = $this->ctrler->__getWebsiteInfo($websiteId)) { $websiteInfo['oldName'] = $websiteInfo['name']; // loop through inputs foreach ($info as $key => $val) { $websiteInfo[$key] = $val; } // update website call as api call $this->ctrler->spTextWeb = $this->ctrler->getLanguageTexts('website', SP_API_LANG_CODE); $return = $this->ctrler->updateWebsite($websiteInfo, true); // if website creation is success if ($return[0] == 'success') { $returnInfo['response'] = 'success'; $returnInfo['result'] = $return[1]; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = $return[1]; } } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid website id provided"; } return $returnInfo; } /** * function to delete website * @param Array $info The input details to process the api * $info['id'] The id of the website - Mandatory * @return Array $returnInfo Contains details about the operation success or not */ function deleteWebsite($info) { $websiteId = intval($info['id']); // if website exists if ($websiteInfo = $this->ctrler->__getWebsiteInfo($websiteId)) { $this->ctrler->__deleteWebsite($websiteId); $returnInfo['response'] = 'success'; $returnInfo['result'] = "Successfully deleted website and related data."; } else { $returnInfo['response'] = 'Error'; $returnInfo['error_msg'] = "The invalid website id provided"; } return $returnInfo; } } ?>

Kunal yadav

मेरा नाम कुणाल हैं और में एक ब्लॉगर हूँ और में इस ब्लॉग पर ऐसे पोस्ट डालता हूँ जिनसे आप अपना करियर और पैसे दोनों कमा सको

Post a Comment

Previous Post Next Post

Contact Form