Skip to content

Instantly share code, notes, and snippets.

@RoboSparrow
Last active April 13, 2017 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoboSparrow/eceba75bf1c86755f59f0e2d760bf000 to your computer and use it in GitHub Desktop.
Save RoboSparrow/eceba75bf1c86755f59f0e2d760bf000 to your computer and use it in GitHub Desktop.
<?php
/**
* @see https://github.com/Brightcookie/lxHive/issues/91
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$LRS = array(
'endpoint' => '<endpoint_without_slash>',
'version' => '1.0.1',
'user' => '<user>',
'password' => '<password>',
);
$url = $LRS['endpoint'].'/statements?limit=2';
$http = array(
'max_redirects' => 0,
/////
// access_log output when changing setting "request_fulluri" below
//
// GOOD ('request_fulluri' => 0) 127.0.0.1 - "GET /statements?limit=2 HTTP/1.0" 200 1749 "-" "-"
// BAD ('request_fulluri' => 1) 127.0.0.1 - "GET http://lxhive.bo/statements?limit=2 HTTP/1.0" 404 678 "-" "-"
//
// !!!!!!!!!!! slim Router::getMatchedRoute receives arg $resourceUri as s'/http://lxhive.bo/statements'
//
/////
'request_fulluri' => 1, // 0
'ignore_errors' => true, //false
'method' => 'GET',
'header' => array(
'X-Experience-Api-Version: '.$LRS['version'],
'Authorization: Basic '.base64_encode($LRS['user'].':'.$LRS['password']),
)
);
$context = stream_context_create(array( 'http' => $http ));
var_dump(stream_context_get_options($context));
$fp = fopen($url, 'rb', false, $context);
if (! $fp) {
throw new Exception('We are done for! $php_errormsg');
}
$meta = stream_get_meta_data($fp);
$content = stream_get_contents($fp);
var_dump($meta);
var_dump($content);
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment