【发布时间】:2016-12-22 16:16:57
【问题描述】:
我正在使用 GrapheneDB,我尝试重新使用我用来从 AWS 服务器连接到 Neo4J 服务器的代码。但它没有将数据插入 GrapheneDB,我不知道这里出了什么问题。以前,我使用过localhost:7474,但现在我使用的是以下 URL。我怎样才能让它工作?
$http="http://username:password@hobby-1312.dbs.graphenedb.com:2789/db/data/cypher/";
$data =' MERGE (a:User {name:"name",id:"id" }) ';
$data = array("query" =>$data);
$data_string = json_encode($data);
$ch = curl_init($http);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
【问题讨论】:
-
您从 Neo4j 得到的回应是什么?可以添加http响应码和响应体吗?
-
我该怎么做?
-
我已添加:$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($result, 0, $header_size); $body = substr($result, $header_size);我得到 0 作为响应
标签: php curl neo4j graphenedb