a solution
似乎返回的对象类型(
EasyRdf_Graph
/
EasyRdf_Sparql_Result
)视情况而定
Accept
标头的参数。我试图修改它(添加了中列出的不同内容类型)
Virtuoso doc
)通过Firebug重新发送请求,但没有收到任何请求
EasyRdf\ U图
正如Ted所问,下面是请求头的相关部分(使用上面的php代码和EasyRDF 0.0.1):
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
print_r(get_headers($endpointUrl));
下面是Fuseki的响应头(它给出了一个
对象):
[0] => HTTP/1.1 200 OK
[1] => Date: Tue, 11 Sep 2018 06:14:56 GMT
[2] => Fuseki-Request-ID: 13
[3] => Vary: Accept,Accept-Encoding,Accept-Charset
[4] => Content-Type: application/n-quads
[5] => Vary: User-Agent
http://data.bnf.fr
)
[0] => HTTP/1.1 302 Found
[1] => Date: Tue, 11 Sep 2018 06:12:29 GMT
[2] => Server: Apache
[3] => Location: http://data.bnf.fr/sparql/
[4] => Content-Length: 210
[5] => Content-Type: text/html; charset=iso-8859-1
[6] => Vary: Accept-Encoding,User-Agent
[7] => Connection: close
[8] => HTTP/1.1 200 OK
[9] => Date: Tue, 11 Sep 2018 06:12:29 GMT
[10] => Server: Apache
[11] => Last-Modified: Mon, 19 Feb 2018 10:34:21 GMT
[12] => ETag: "200036-3a99-5658e3ca8a540"
[13] => Accept-Ranges: bytes
[14] => Content-Length: 15001
[15] => Vary: Accept-Encoding,User-Agent
[16] => Access-Control-Allow-Origin: *
[17] => Content-Type: text/html
[18] => Content-Language: fr
[19] => Connection: close
注:用于数据.bnf.fr代码是302(重定向),但似乎没有任何区别,请参阅dbpedia响应:
[0] => HTTP/1.1 200 OK
[1] => Date: Tue, 11 Sep 2018 07:17:23 GMT
[2] => Content-Type: text/html; charset=UTF-8
[3] => Content-Length: 14172
[4] => Connection: close
[5] => Vary: Accept-Encoding
[6] => Server: Virtuoso/07.20.3229 (Linux) i686-generic-linux-glibc25-64 VDB
[7] => Expires: Tue, 18 Sep 2018 07:17:23 GMT
[8] => Cache-Control: max-age=604800
[9] => Access-Control-Allow-Origin: *
[10] => Access-Control-Allow-Credentials: true
[11] => Access-Control-Allow-Methods: GET, POST, OPTIONS
[12] => Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Encoding
[13] => Accept-Ranges: bytes
使用新php代码和composer更新的解决方案
1) 编辑编写器.json:
{
"require": {
"easyrdf/easyrdf": "dev-master"
}
}
php composer.phar update
3) 重写php代码:
require_once './third_party/vendor/autoload.php';
$endpointUrl = "http://data.bnf.fr/sparql";
$dummyConstructQueryString = "construct { ?s ?q ?r } where { ?s ?p ?o . ?o ?q ?r } limit 1";
$endPoint = new \EasyRdf\Sparql\Client($endpointUrl); // <-- here use the namespace
$result = $endPoint->query($dummyConstructQueryString);
var_dump($result);
编辑
EasyRdf\ U图
对象。以下是请求和响应的标头,带有更新的Easyrdf代码(“dev master”版本)。也许EasyRDF解析查询和结果来构建一个
EasyRdf\ U图
-
Host: localhost
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
-
回应
http://data.bnf.fr/sparql/
(通过以下方式获得)
print_r(get_headers($endpointUrl));
[0] => HTTP/1.1 302 Found
[1] => Date: Wed, 12 Sep 2018 06:21:48 GMT
[2] => Server: Apache
[3] => Location: http://data.bnf.fr/sparql/
[4] => Content-Length: 210
[5] => Content-Type: text/html; charset=iso-8859-1
[6] => Vary: Accept-Encoding,User-Agent
[7] => Connection: close
[8] => HTTP/1.1 200 OK
[9] => Date: Wed, 12 Sep 2018 06:21:48 GMT
[10] => Server: Apache
[11] => Last-Modified: Mon, 19 Feb 2018 10:34:21 GMT
[12] => ETag: "200036-3a99-5658e3ca8a540"
[13] => Accept-Ranges: bytes
[14] => Content-Length: 15001
[15] => Vary: Accept-Encoding,User-Agent
[16] => Access-Control-Allow-Origin: *
[17] => Content-Type: text/html
[18] => Content-Language: fr
[19] => Connection: close