I have a piece of code that is written in PHP and uses the ARC2 library to fetch data from an endpoint via SPARQL.
<?php
include 'includes/config.php';
include_once('semsol/ARC2.php'); /* ARC2 static class inclusion */
$dbpconfig = array(
"remote_store_endpoint" => "http://landregistry.data.gov.uk/",
);
$store = ARC2::getRemoteStore($dbpconfig);
if ($errs = $store->getErrors()) {
echo "<h1>getRemoteSotre error<h1>" ;
}
$query = 'prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix sr: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
prefix ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>
prefix lrppi: <http://landregistry.data.gov.uk/def/ppi/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix lrcommon: <http://landregistry.data.gov.uk/def/common/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX app: <http://example.com#>
SELECT DISTINCT
?regionName ?date ?ukhpi ?volume
WHERE
{
values ?newport {<http://landregistry.data.gov.uk/data/ukhpi/region/newport/month/2013-10>}
?newport
ukhpi:refRegion ?region;
ukhpi:refMonth ?date;
ukhpi:housePriceIndex ?ukhpi.
OPTIONAL {
?newport ukhpi:salesVolume ?volume
}
?region rdfs:label ?regionName .
FILTER (langMatches( lang(?regionName), "EN") )
';
$rows = $store->query($query, 'rows'); /* execute the query */
if ($errs = $store->getErrors()) {
echo "Query errors" ;
pr($errs);
}
$rows = $store->query($query); /* execute the query */
pr($rows);
?>
This connects to the API endpoint OK, but the error message I get in the browser is:
Query errors
Array
(
[0] => Incomplete or invalid Group Graph pattern. Could not handle " values ?newport {
Array
(
[result] =>
[query_time] => 1.1920928955078E-6
)