Skip to content
Snippets Groups Projects
Commit 29ae19b2 authored by Andrew Downes's avatar Andrew Downes Committed by Ryan Smith
Browse files

fix: Avoids sending invalid JSON to the LRS. (#364)

parent ca9a506c
Branches
No related tags found
No related merge requests found
...@@ -29,6 +29,10 @@ function load(array $config, array $events) { ...@@ -29,6 +29,10 @@ function load(array $config, array $events) {
$auth = base64_encode($username.':'.$password); $auth = base64_encode($username.':'.$password);
$postdata = json_encode($statements); $postdata = json_encode($statements);
if ($postdata === false) {
throw new \Exception('JSON encode error: '.json_last_error_msg());
}
$request = curl_init(); $request = curl_init();
curl_setopt($request, CURLOPT_URL, $url); curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_POSTFIELDS, $postdata); curl_setopt($request, CURLOPT_POSTFIELDS, $postdata);
......
...@@ -35,6 +35,10 @@ function load(array $config, array $events) { ...@@ -35,6 +35,10 @@ function load(array $config, array $events) {
$auth = base64_encode($username.':'.$password); $auth = base64_encode($username.':'.$password);
$postdata = json_encode($statements); $postdata = json_encode($statements);
if ($postdata === false) {
throw new \Exception('JSON encode error: '.json_last_error_msg());
}
$request = new \curl(); $request = new \curl();
$responsetext = $request->post($url, $postdata, [ $responsetext = $request->post($url, $postdata, [
'CURLOPT_HTTPHEADER' => [ 'CURLOPT_HTTPHEADER' => [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment