示例#1
0
文件: api.php 项目: pritcham/XenAPI
                                // User does not have permission to use this action, throw error.
                                if ($restAPI->hasRequest('value') && $restAPI->isUserAction()) {
                                    $restAPI->throwError(9, $restAPI->getAction());
                                } else {
                                    $restAPI->throwError(10, $restAPI->getAction());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
// Process the request.
$restAPI->processRequest();
class RestAPI
{
    const VERSION = '1.4.1';
    const DEFAULT_APIKEY = 'REPLACE_THIS_WITH_AN_API_KEY';
    const GENERAL_ERROR = 0x201;
    const USER_ERROR = 0x202;
    const THREAD_ERROR = 0x203;
    const POST_ERROR = 0x204;
    /**
     * Contains all the actions in an array, each action is 'action' => 'permission_name'
     * 'action' is the name of the action in lowercase.
     * 'permission_name' is the permission requirement of the action, see description under.
     *
     * Permission names and meaning:
     *   - public:        A hash is not required to use this action, it can be used without
示例#2
0
文件: api.php 项目: sakonet/kunstquiz
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
require_once realpath('core/class.restapi.php');
// require_once(realpath('core/lib.xml.php'));
// Requests from the same server don't have a HTTP_ORIGIN header
if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) {
    $_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME'];
}
try {
    $api = new RestAPI($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']);
    echo $api->processRequest();
} catch (Exception $e) {
    echo json_encode(array('Error' => $e->getMessage()));
}