PHP connection to SPARQL endpoints
<?php
//phpinfo();
function dbpediaSPARQL(){
$query = "SELECT * {?s ?p ?o.} LIMIT 10";
$searchUrl = 'http://dbpedia.org/sparql?'
. 'query='.urlencode($query)
. '&format=json';
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, $searchUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print ($response);
}
// dbpediaSPARQL();
function CELLARSPARQL(){
$query = "SELECT * {?s ?p ?o.} LIMIT 10";
$searchUrl = 'http://publications.europa.eu/webapi/rdf/sparql?query=' .
urlencode($query) . '&format=json';
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, $searchUrl);
curl_setopt($ch, CURLOPT_USERAGENT, "Google Chrome Browser");
curl_setopt($ch, CURLOPT_HEADER, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
$response = curl_exec($ch);
curl_close($ch);
print ($response);
}
CELLARSPARQL();
?>