Example #1
0
<?php

/** @file
*	@brief Public RESTful API for retrieving Items
**/
require_once __DIR__ . "/../../api.php";
// CMW API //
$out = json_NewResponse();
$out['item'] = 1;
//$out['args'] = $_GET;
//$out['server'] = $_SERVER;
$out['parsed'] = core_ParseActionURL();
/**
 * @api {GET} /v1/get/:item /v1/get
 * @apiName GetItem
 * @apiGroup Core
 * @apiPermission Everyone
 * @apiVersion 0.1.0
 *
 * @apiDescription Retrieve an item
*/
/**
 * @api {GET} /v1/games[/:offset] /v1/games
 * @apiName GetGames
 * @apiGroup Popular
 * @apiPermission Everyone
 * @apiVersion 0.1.0
 *
 * @apiDescription YOU GOT GAME?
*/
/**
Example #2
0
<?php

/**	@file
*	@brief Internal AJAX API for managing Users (Login, Logout, Register, Delete, etc)
**/
require_once __DIR__ . "/../../api.php";
require_once __DIR__ . "/../../core/users.php";
require_once __DIR__ . "/../../core/node.php";
require_once __DIR__ . "/../../core/internal/sanitize.php";
$response = json_NewResponse();
// Retrieve Session, store User ID
user_StartEnd();
$response['id'] = user_GetID();
// Retrieve Action and Arguments
$arg = core_ParseActionURL();
$action = array_shift($arg);
$arg_count = count($arg);
// Bail if not an HTTP POST
//if ( $action !== 'verify' ) {
//	if ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
//		json_EmitError();
//	}
//}
// Confirm we have a legal number of arguments
if ($arg_count > 1) {
    json_EmitError();
}
// On 'login' Action, attempt to log-in given POST data.
/**
 * @api {POST} /a/user/login /a/user/login
 * @apiName UserLogin
Example #3
0
function json_Begin()
{
    global $RESPONSE, $REQUEST;
    // Begin //
    $RESPONSE = json_NewResponse();
    // Authenticate //
    user_Auth();
    if (isset($_GET['auth']) || isset($_GET['debug'])) {
        // Need to limit what keys get copied. No need to send a full user (or accidentilaly send private info)
        $keys = ['id'];
        //,'admin','permission'];
        $RESPONSE['auth'] = array_intersect_key($_SESSION, array_flip($keys));
    }
    // Load Globals //
    global_Load();
    json_CheckForMaintenence();
    // Parse Arguments //
    $REQUEST = core_GetAPIRequest();
    if (isset($_GET['request']) || isset($_GET['debug'])) {
        $RESPONSE['request'] = $REQUEST;
    }
}