/** * Call an API if you're using this inside your application * @string $api The API name, or path for example : "thread/path2/path3" * @array $options ["username" => username, "password" => password], "output", "username" and "password" are optional * @array $parameters optional, parameters to pass to the API * @return stdClass object the result of the API * @throws RESTfulException is the API throws an error */ public function call($api, $parameters = array(), $options = array()) { global $mybb; $apiclone = new self($api); $apiclass = strpos($api, "/") !== false ? substr($api, 0, strpos($api, "/")) : $api; $api_instance = $apiclone->_build_api_instance_from_class($apiclass); if (empty($api_instance)) { throw new UnauthorizedException($lang->restfulapi_no_permission); } else { if (isset($options["username"]) && is_string($options["username"]) && isset($options["password"]) && is_string($options["password"])) { $apiclone->_authenticate_user($options["username"], $options["password"]); } $inputclone = $mybb->input; $mybb->input = array_merge($mybb->input, $parameters); $result = $api_instance->action(); $mybb->input = $inputclone; return $result; } }