Created
December 6, 2018 10:48
Weengs Pre Spaghetti Exaplme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// include environment related files | |
include_once '../inc/env.inc.php'; | |
// will return JSON response | |
header('Content-type: application/json'); | |
WEApplication::serviceAvailabilityCheck(); | |
$secretDev = isset($_POST['secret_dev']) ? $_POST['secret_dev'] : ''; | |
$pending = isset($_POST['pending']) ? $_POST['pending'] : 0; | |
if ($secretDev != _WE_SECRET_DEV_KEY_) { | |
die('{"result":"ERROR","code":"1","error":"Incorrect secret key"}'); | |
} | |
// Successful response | |
$JSON = '{'; | |
$JSON .= '"result":"OK",'; | |
$JSON .= '"shops":['; | |
$shops= WEShop::shops(array('pending'=>$pending)); | |
$i=0; | |
foreach ($shops as $shop) { | |
if ($i>0) { | |
$JSON.=','; | |
} | |
++$i; | |
$JSON.=$shop->propertiesAsJSON(); | |
} | |
$JSON.='],'; | |
$JSON .= '"teams":['; | |
$teams= WETeam::getTeams(); | |
$i=0; | |
foreach ($teams as $team) { | |
if ($i>0) { | |
$JSON.=','; | |
} | |
++$i; | |
$JSON.=$team->propertiesAsJSON(); | |
} | |
$JSON.=']}'; | |
echo $JSON; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment