【发布时间】:2015-08-30 21:34:17
【问题描述】:
在我的应用程序中,我想使用我的 php 脚本向我的 cartodb-table 发送少量数据。 我想使用SQL-API。我的应用程序以如下形式解析数据:
https://{account}.cartodb.com/api/v2/sql?q=INSERT INTO test_table (column_name, column_name_2, the_geom) VALUES ('this is a string', 11, ST_SetSRID(ST_Point(-110, 43),4326))&api_key={Your API key}
我尝试了几个函数http_get, file_get_contents, http_request,但没有将数据传递到我的帐户。当我复制/粘贴 URL 并在浏览器中打开时,所有内容都已添加。
什么是正确的功能?有很多不同的...PHP-HTTP-Functions
编辑
使用来自this solution 的代码,当我打印出响应时出现此错误:
{"error":["syntax error at end of input"]}
在浏览器中我得到这个:
{"rows":[],"time":0.038,"fields":{},"total_rows":1}
我现在的请求代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullurl);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Get the response and close the channel.
$response = curl_exec($ch);
curl_close($ch);
print($response);
【问题讨论】:
-
可能是证书问题,因为它是在 https 上请求的,看看这个answer
-
我收到回复的作品。但我收到错误 {"error":["You must specify a sql query"]}
-
您能否编辑问题以包含错误消息?
-
用代码和错误编辑我的帖子