2008-11-14

ARC2 and Triplify

I have been using Triplify to publish the MySQL world example database as linked data (see results here). I also tried out ARC2 to start messing about with PHP and SPARQL. Unfortunately the two don't currently play nicely together because ARC2's parsers don't like Triplify's N3 output. Fortunately we can use a back-door via CURL and SPARQL to work some magic.

function fetchURLAndStore($arc2store, $into, $url) {    
  $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL,$url);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,true);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);
  $q = 'INSERT INTO <' . $into . '> { ' . $buffer . ' }'
  $arc2store->query($q);
}