Commit 2a327c6a authored by Francois Gannaz's avatar Francois Gannaz
Browse files

HTTP GET cannot pass a payload in its body

parent c9ffd8fb
......@@ -140,9 +140,12 @@ class mod_labnbook_session
protected function fetch($verb, $urlPath, $defaultValue = null, $payload = []) {
$payload['key'] = $this->secret;
$curl = curl_init();
if ($verb === 'GET') {
$urlPath .= (strpos($urlPath, '?') === false ? "?" : "&") . "key=" . rawurlencode($this->secret);
}
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST, $verb,
CURLOPT_CUSTOMREQUEST => $verb,
CURLOPT_URL => $this->url . "/api/index.php" . $urlPath,
CURLOPT_HTTPHEADER, ['Content-Type:application/json', 'Accept:application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment