コード例 #1
0
ファイル: _Command.php プロジェクト: davidAtGVC/WebHelpDesk
function WebHelpDesk_Command($resource = '', $params = array(), $qualifier = null, $configName = CONFIG_Tech_Key)
{
    if (is_null($resource) || strlen($resource) == 0) {
        throw new \Exception('No request resource specified');
    }
    $config = testConfig($configName);
    if (is_array($config) && isset($config[CONFIG_base])) {
        $reqParams = array("login" => $config[CONFIG_user], "password" => $config[CONFIG_password]);
        if (is_array($params)) {
            $reqParams = array_merge($params, $reqParams);
        }
        $q = '';
        if (is_string($qualifier)) {
            $q = "&" . Qualifier_Operation::OP . "=" . $qualifier;
        }
        $url = $config[CONFIG_base] . "/ra/" . $resource . "?" . http_build_query($reqParams) . $q;
        echo $url . PHP_EOL;
        list($data, $headers) = performGET($url);
        if ($data != false) {
            $json = json_decode($data, true);
            if (json_last_error() != 0) {
                throw new \Exception(jsonErrorString(json_last_error()));
            }
            return array($json, $headers);
        }
    }
    throw new \Exception('Please update the configuration for ' . $configName);
}
コード例 #2
0
<?php

$system_path = dirname(dirname(__FILE__));
if (realpath($system_path) !== FALSE) {
    $system_path = realpath($system_path) . DIRECTORY_SEPARATOR;
}
define('SYSTEM_PATH', str_replace("\\", DIRECTORY_SEPARATOR, $system_path));
require SYSTEM_PATH . 'Tests/_Base.php';
require SYSTEM_PATH . 'Tests/_Enums.php';
require SYSTEM_PATH . 'Tests/_Command.php';
//curl "https://localhost/helpdesk/WebObjects/Helpdesk.woa/ra/Tickets/1?username=admin&password=admin"
$config = testConfig(CONFIG_Client_Key);
if (is_array($config) && isset($config[CONFIG_base])) {
    $params = array("list" => "mine", "username" => $config[CONFIG_user], "password" => $config[CONFIG_password]);
    $resource = "Tickets";
    $url = $config["base"] . "/ra/" . $resource . "/?" . http_build_query($params);
    echo $url . PHP_EOL;
    $result = performGET($url);
    echo json_encode($result, JSON_PRETTY_PRINT) . PHP_EOL;
}
exit;