Skip to content

Instantly share code, notes, and snippets.

@thiagomarini
Created December 6, 2018 10:48
Show Gist options
  • Save thiagomarini/c84f1babc8588cfa93a94a27e4a60607 to your computer and use it in GitHub Desktop.
Save thiagomarini/c84f1babc8588cfa93a94a27e4a60607 to your computer and use it in GitHub Desktop.
Weengs Pre Spaghetti Exaplme
<?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