Beispiel #1
0
        $func = 'get' . $uctype . ($asResponse ? 'Response' : '');
        if (substr($returnFormat, 0, 4) == 'json') {
            $response = self::$func($key, $context, 'json', $groupID);
            if ($returnFormat == 'json' || $returnFormat == 'jsonResponse') {
                return $response;
            }
            if ($returnFormat == 'jsonData') {
                return $response['data'];
            }
        }
        // Request Atom
        $response = self::$func($key, $context, 'atom', $groupID);
        if ($returnFormat == 'atom' || $returnFormat == 'atomResponse') {
            return $response;
        }
        $xml = self::getXMLFromResponse($response);
        $data = self::parseDataFromAtomEntry($xml);
        if ($returnFormat == 'data') {
            return $data;
        }
        if ($returnFormat == 'content') {
            return $data['content'];
        }
        if ($returnFormat == 'atomJSON') {
            return json_decode($data['content'], true);
        }
        throw new Exception("Invalid result format '{$returnFormat}'");
    }
}
API3::loadConfig();