Example for an HTTP Webservice in PHP

In this section you can find an example for using a SPARQL query template.

It retrieves the labels of a concept for creating an http webservice in php using the ARC library (see Available Clients).


// include ARC2 libraries

// configure the remote store
$configuration = array('remote_store_endpoint'  => '<link to the sparql endpoint>');
$store = ARC2::getRemoteStore($configuration);

// the sparql query
$query = "
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT ?label
  { <$CONCEPT_URI> skos:prefLabel ?label.} UNION
  { <$CONCEPT_URI> skos:altLabel ?label.} UNION
  { <$CONCEPT_URI> skos:hiddenLabel ?label.}
  FILTER (lang(?label) = '$LANGUAGE')

// get the response from the sparql endoint
$rows = $store->query($query, 'rows');

echo 'The concept has the following labels:';
foreach ($rows as $row) {
    echo $row['label'] . '<br />';