【发布时间】:2023-04-07 03:37:01
【问题描述】:
我正在尝试使用 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 (得到 application/n-triples)' in 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>
谢谢。
【问题讨论】:
标签: php rdf fuseki easyrdf graph-store-protocol