CartoDB-sqlapi-Post请求与php

CartoDB-sqlapi-Post请求与php,php,http,cartodb,Php,Http,Cartodb,在我的应用程序中,我想用我的php脚本向我的cartodb表发送少量数据。 我想用这个。我的应用程序以如下形式解析数据: 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={Yo

在我的应用程序中,我想用我的php脚本向我的cartodb表发送少量数据。 我想用这个。我的应用程序以如下形式解析数据:

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\u-get、file\u-get\u-contents、http\u-request
,但没有将数据传递到我的帐户。当我复制/粘贴URL并在浏览器中打开时,所有内容都已添加

正确的函数是什么?有那么多不同的

编辑

使用来自的代码,当我打印响应时,我得到此错误:

{"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);

找到结果:使用
CURLOPT_POST=>1
它可以工作

$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://".$cartodb_key.".cartodb.com/api/v2/sql",
CURLOPT_USERAGENT => 'Sample cURL Request',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
    api_key => $api_key,
    q => "INSERT INTO spot (".implode (", ", array_keys($data)).") VALUES (".implode (", ", $data).")"
  )
));
$response = curl_exec($ch);
curl_close($ch);

可能是证书问题,因为它是在https上请求的,看看这个作品,我得到了e响应。但是我得到了错误{“error”:[“你必须指明一个sql查询”]}你能编辑这个问题以包含错误消息吗?用代码和errorGreat编辑我的帖子,你自己找到了解决方案