我正在尝试使用 Apache Jena Fuseki 运行 EasyRDF 库中的示例代码,但是在将数据输入数据库时出现以下错误:
致命错误:未捕获的异常 'EasyRdf_Exception' 带有消息 'HTTP 请求 http:// localhost:3030/test/update?graph=http%3A%2F%2Flocalhost%3A3030%2Ftest%2Ftime.rdf 失败:必须是 application/sparql -update 或 application/x-www-form-urlencoded (got application/n-triples)' 在 D:\Files\xampp\htdocs\test\easyrdf-0.9.0\lib\EasyRdf\GraphStore.php:152 堆栈跟踪: #0 D:\Files\xampp\htdocs\test\easyrdf-0.9.0\lib\EasyRdf\GraphStore.php(217): EasyRdf_GraphStore->sendGraph('POST', Object(EasyRdf_Graph), 'time.rdf' , 'ntriples') #1 D:\Files\xampp\htdocs\test\graphstore.php(34): EasyRdf_GraphStore->insert(Object(EasyRdf_Graph), 'time.rdf') #2 {main} 在 D 中抛出: \Files\xampp\htdocs\test\easyrdf-0.9.0\lib\EasyRdf\GraphStore.php 在第 152 行
按照代码:
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "easyrdf-0.9.0/lib/EasyRdf.php";
?>
<html>
<head>
<title>GraphStore example</title>
</head>
<body>
<?php
// Use a local SPARQL 1.1 Graph Store (eg RedStore)
$gs = new EasyRdf_GraphStore('http://localhost:3030/test/update');
// Add the current time in a graph
$graph1 = new EasyRdf_Graph();
$graph1->add('http://example.com/test', 'rdfs:label', 'Test');
$graph1->add('http://example.com/test', 'dc:date', time());
$gs->insert($graph1, 'time.rdf');
// Get the graph back out of the graph store and display it
$graph2 = $gs->get('time.rdf');
print $graph2->dump();
?>
</body>
</html>
谢谢。