Hi everyone, I'm using ontop CLI (https://ontop-vkg.org/tutorial/interact/cli.html) to do Sparql queries. I would like to redo this example using the \EasyRdf\Sparql\Client:
POST http://localhost:8080/sparql
Content-Type: application/sparql-query
Accept: application/json
PREFIX : <http://example.org/voc#>
SELECT DISTINCT ?teacher {
?teacher a :Teacher .
}
I tried as follows using \EasyRdf\Sparql\Client:
\EasyRdf\RdfNamespace::set('fo','http://www.w3.org/1999/XSL/Format#');
\EasyRdf\RdfNamespace::set('','http://example.org/voc');
\EasyRdf\RdfNamespace::set('foaf', 'http://xmlns.com/foaf/0.1/');
$sparql = new \EasyRdf\Sparql\Client('http://localhost:8080/sparql');
//$sparql = \EasyRdf\Http\Client::setHeaders('accept', 'application/json');
$result = $sparql->query(
'SELECT ?title WHERE {
?x a :ServiceProfile ; :serviceTitle ?title
}'
);
dd($result);
But I'm getting an empty query and I haven't even found a way to add headers. Does anyone have a solution for this?
EasyRdf\Sparql\Result {#284 ▼ -type: "bindings" -boolean: null -fields: array:1 [▼ 0 => "title" ] -parseState: [] -storage: [] flag::STD_PROP_LIST: false flag::ARRAY_AS_PROPS: false }
In this case the result of the query should be the same as the image below