Skip to content

Instantly share code, notes, and snippets.

@jctoledo
Created July 22, 2013 14:18
Show Gist options
  • Save jctoledo/6054161 to your computer and use it in GitHub Desktop.
Save jctoledo/6054161 to your computer and use it in GitHub Desktop.
Using Limit and offset in a SPARQL query with PHP
<?php
$myQuery = "select * where{?x ?y ?z}";
$result = getFromEndpoint(urlencode($myQuery), 10, 10);
if($result != null){
print_r($result);
}
function getFromEndpoint($query, $limit, $offset){
$f = file_get_contents("http://cu.gene.bio2rdf.org/sparql?default-graph-uri=&query=".$query."+limit+".$limit."+offset+".$offset."&format=xml%2Fhtml&timeout=0");
if($f != null && strlen($f)>0){
return $f;
}else{
return null;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment