- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 SPARQL 的新手,所以这可能是一个愚蠢的问题,但我在插入数据时遇到了问题。我正在使用 HTTPS REST 端点与数据库通信。
我有以下三元组:
<urn:data:Gen`000001>
<urn:data:content>
"This is a literal"
我 urlencode()
因为,正如我所想,它不会给我任何错误,因为它具有正确的 URI 格式:
<urn:data:Gen%60000001>
...
但是 % 字符引发错误(因为如果我使用 -
而不是 %
它会起作用。)因为 this answer我尝试反斜杠 %
字符:
<urn:data:Gen\%60000001>
...
然后我尝试使用 URL 而不是 URN:
<https://test.com/data/Gen%60000001>
<https://test.com/data/content>
...
但它一直给我同样的错误:
The requested URL returned error: 400 Bad Request
那我做错了什么?我怎样才能转义 %
字符(也许还有其他 urlencode 字符?)或者我应该问,这是正确的做法吗,在提交之前执行 urlencode()
?
编辑:
我的 PHP 代码:
$q = 'update=INSERT DATA { '.
'<https://test.com/data/Gen%60000001> '.
'<https://test.com/data/content> '.
'"This is a literal." }';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$config->db->public->neptune->cluster."/sparql");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $q);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
if (curl_errno($ch)) {
$error = curl_error($ch);
}
if(!$error)
echo $server_output;
else
echo $error;
同样,如果我只是将 %
更改为 -
它会起作用:
query=select * where {?s ?p ?o}
result:
"s" : {
"type" : "uri",
"value" : "https://test.com/data/Gen-60000001"
},
"p" : {
"type" : "uri",
"value" : "https://test.com/data/content"
},
"o" : {
"type" : "literal",
"value" : "This is a literal."
}
EDIT2 + 解决方案:
正如 Kelvin Lawrence 所指出的,这很可能是 PHP 方面的一些解析/编码问题。我删除了 CURLOPT_FAILONERROR
,现在出现了这些错误:
using URN:
{
"detailedMessage":"Malformed query: Lexical error at line 1, column 28.
Encountered: \"`\" (96), after : \"\"",
"requestId":"***",
"code":"MalformedQueryException"
}
using URL:
{
"detailedMessage":"Malformed query: Lexical error at line 1, column 32.
Encountered: \"/\" (47), after : \"test.com\"",
"requestId":"***",
"code":"MalformedQueryException"}
看起来使用 URN 的错误表明 Neptune 在我对其进行 urlencode 之前将其接收(或解码)为原始字符。因此,如果我在发送之前再次对它进行 urlencode,它就可以正常工作:
$q = 'update=INSERT DATA { '.
'<https://test.com/data/'.urlencode(urlencode('Gen`60000001')).'> '.
'<https://test.com/data/content> '.
'"This is a literal." }';
但是 为什么 Neptune 接收它是解码的,或者它为什么要解码它? 它是在 POST 正文中发送的,所以不需要解码,对吧?我错过了什么?
编辑 3:
还有一点我要提一下:
$q = 'query=select * where {?s ?p ?o}';
此查询完美运行,而带有换行符的相同查询不起作用:
$q = 'query=select *
where {
?s
?p
?o
}';
它给我这个错误:
{
"detailedMessage":"Malformed query: Encountered \"\" at line 1, column 9.\n
Was expecting one of:\n \"{\" ...\n \"from\" ...\n \"where\" ...\n
\"with\" ...\n ",
"requestId":"***",
"code":"MalformedQueryException"
}
为什么?我可以通过将查询保留在一行来解决这个问题,但这不是它应该的工作方式。
最佳答案
尝试使用 base64_encode/decode。在 php 文件之间传输数据对我来说很有效
文件A:$string = "sadfkjæ4#%"#¤%";$string_for_transfer = base64_encode($string);
文件 B:
$string = $_GET["string"];
$string_data = base64_decode($string);
echo $string_data;
给出:
sadfkjæ4#%"#¤%
关于PHP curl : Encoding/Parsing (AWS Neptune using SPARQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63922585/
我发现在使用parse-node包时,不能再使用Parse.Cloud.httpRequest了。我也知道 Parse 的 Image 对象将不可用。 到目前为止,我已经能够用原生的替换一些 Pars
关闭。这个问题是opinion-based 。目前不接受答案。 已关闭 9 年前。 已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 我有一个函
开源 Parse Server 是否包含用于配置新 Parse 实例的 Schema API?我试图消除手动创建应用程序的需要。 这是通过 Parse.com 提供的架构 API http://blo
我想从我的云代码发出一个 http 请求,该请求在我的客户端被调用。 最佳答案 一开始我发现这有点令人困惑,所以希望这会有所帮助。 在您的云代码中main.js Parse.Cloud.define(
这部分代码应该读入两个或更多数字(省略主 io 函数),然后是一个“+”来给出总和。使用有理数是因为稍后我将进行乘法和其他此类操作。 data Expression = Number Rationa
我似乎找不到任何关于此的官方信息:Does Parse.Config work on Parse Server?它曾经在 Parse.com 上工作,但是当我尝试迁移到 Parse.Server 时,
我正在尝试找到使用 Parse.com 添加密码要求的最佳程序。似乎最简单的方法是在保存用户数据之前使用云功能执行。我唯一的警告是,只有当密码与数据库中存储的密码不同或者用户不存在于数据库中时,我才想
我是 android 开发、应用程序开发和一般开发的初学者,我正在尝试为我的 android 应用程序设置后端数据库。我决定使用一个名为 back4app 的服务,以便获得更加用户友好的数据库体验,因
我目前正在尝试将 Facebook 登录功能添加到我的应用程序。 根据Android文档,当我添加 compile 'com.parse:parsefacebookutils-v4-android:1
我正在尝试使用 Rebol 2/3 从字符串中解析货币值,货币值的格式为: 10,50 欧元或 10,50 欧元 我在浏览了所有 PARSE 文档后想出了这段代码,我可以在 Red 中找到它,但在 R
代码: DateTimeFormat dateFormat = DateTimeFormat .getFormat("EEE MMM dd HH:mm:ss zzz y
我不再在 Parse 上看到用于导入 JSON 或 CSV 文件的导入按钮。他们是否将其移动到某个地方,或者不再可能导入这些文件类型? 最佳答案 官方原因是这样的: “[导入类按钮] 几天前被删除,因
我正在使用 PHP 从我的服务器检索一些数据。我想在 javascript 应用程序中使用这些数据,所以我正在做这样的事情: var polylines = ; $polylines 只是一个 PHP
我已经开始使用 .NET 4 System.Numerics.BigInteger Structure我遇到了一个问题。 我正在尝试解析一个包含无符号(正数)的十六进制数字的字符串。我得到一个负数。
我正在使用 PHP 从我的服务器检索一些数据。我想在 javascript 应用程序中使用这些数据,所以我正在做这样的事情: var polylines = ; $polylines 只是一个 PHP
在 Go 中,尝试将字符串转换为 time.Time 时,使用时间包的 Parse 方法不会返回预期结果。似乎问题出在时区。我想更改为 ISO 8601 结合 UTC 日期和时间。 package m
我正在尝试将此字符串模式 "4-JAN-12 9:30:14" 解析为 time.Time。 尝试了 time.Parse("2-JAN-06 15:04:05", inputString) 和许多其
从云代码和解析开始。使用this . 如何删除所有 Parse 项目以便开始创建新项目?我收到以下错误: “您想要创建一个新应用程序,还是将 Cloud Code 添加到现有应用程序中?输入“(n)e
我在解析云代码时有这个功能: Parse.Cloud.define("testfunction", function(request, response) { var username = r
最近,我在 parse.com 上做了一些测试。我现在面临在后台作业中使用 Parse.Object.saveAll 的问题。 从 parse.com 的文档来看,后台作业可以运行 15 分钟。我现在
我是一名优秀的程序员,十分优秀!